Reinstall mysql server using Ubuntu Terminal

To remove or uninstall Mysql Client Core 5.5 separately, I used the following commands:

sudo apt-get remove –purge mysql-server mysql-client mysql-common
sudo apt-get remove –purge mysql-client-core-5.5
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /var/lib/mysql

Now install or reinstall mysql client and server:

sudo apt-get install mysql-server
sudo apt-get install mysql-client
sudo apt-get install mysql-workbench


How to add new button box – odoo

class Employee(models.Model):
    _inherit = "hr.employee"

    def view_onboard(self):
        onboard_ids = []
        action = self.env.ref('feag_hr.open_view_onboarding_action').read()[0]

        onboard = self.env['employee.onboard'].search([('name', '=',])
        for data in onboard:

        action['domain'] = [('id', 'in', onboard_ids)]
        return action
<record id="cf_hr_onboard_view_employee_form" model="ir.ui.view">
        <field name="name">hr.employee.form</field>
        <field name="model">hr.employee</field>
        <field name="inherit_id" ref="hr.view_employee_form"/>
        <field name="arch" type="xml">
            <xpath expr="//div[@name='button_box']" position="inside">
                <button name="view_onboard" type="object" string="Onboarding" groups="hr.group_hr_user"
                                    class="oe_stat_button" icon="fa-file-text">

hide edit and create button for users – odoo

        <!-- hiding create and edit button for users -->
        <record id="fair_hide_view_picking_form" model="ir.ui.view">
        <field name="name">stock.picking.form</field>
        <field name="model">stock.picking</field>
        <field name="inherit_id" ref="stock.view_picking_form"/>
        <field name="groups_id" eval="[(4,ref('fair_construction.group_fair_user'))]"/>
        <field name="arch" type="xml">
            <xpath expr="/form" position="attributes">
                <attribute name="create">false</attribute>
                <attribute name="edit">false</attribute>

pdf Print from python function – odoo

Python File

class AMCPaintBooth(models.Model):
    _name = 'amc.paint.booth'    
    def action_amc_jobcard_pb_print(self):
        context = {
                'lang': 'en_US', 
                'active_ids': [], 
                'tz': False, 
                'uid': 1
        return {
            'context': context,
            'data': None,
            'type': '',
            'report_name': 'safe_amc.safe_report_amc_jobcard_pb',
            'report_type': 'qweb-pdf',
            'report_file': 'safe_amc.safe_report_amc_jobcard_pb',
            'name': 'AMC',

xml File

   <button name="action_amc_jobcard_pb_print" string="Print AMC Job Card" icon="fa-bars" type="object" class="oe_highlight"/>

Mysql crashed and won’t start up

  1. Stop mysqld.
  2. Backup /var/lib/mysql/ib*
  3. Add the following line into /etc/my.cnf

innodb_force_recovery = 1 (they suggest 4, but its best to start with 1 and increment if it won’t start)

  1. Restart mysqld.
  2. Dump all tables:# mysqldump -A > dump.sql
  3. Drop all databases which need recovery.
  4. Stop mysqld.
  5. Remove /var/lib/mysql/ib*
  6. Comment out innodb_force_recovery in /etc/my.cnf
  7. Restart mysqld. Look at mysql error log. By default it should be /var/lib/mysql/server/ to see how it creates new ib* files.
  8. Restore databases from the dump:mysql < dump.sql

Get users ids from the group – odoo

    def create(self, vals):
        result = super(HrExpenseAdvances,self).create(vals)        
        group_hr_expense_manager_id = self.env[''].xmlid_to_res_id('hr_expense.group_hr_expense_manager')
        hr_expense_managers = self.get_users_from_group(group_hr_expense_manager_id)
        if hr_expense_managers:
        return result
    #passing group id using self.env[''].xmlid_to_res_id('hr_expense.group_hr_expense_manager')
    def get_users_from_group(self,group_id):
        users_ids = []
        sql_query = """select uid from res_groups_users_rel where gid = %s"""                
        params = (group_id,), params)
        results =
        for users_id in results:
        return users_ids