odoo

How to change a context or domain value from base code – odoo


    <record id="hr.open_view_employee_list_my" model="ir.actions.act_window">
        <field name="context">{'default_employee_type':'permanent'}</field>
    </record>
Advertisements

post follower message – odoo


body = "Follower Message!"

records = self._get_followers(cr, uid, ids, None, None, context=context)
followers = records[ids[0]]['message_follower_ids']
self.message_post(cr, uid, ids, body=body, subtype='mt_comment', partner_ids=followers, context=context)

mail create using python – odoo


@api.model
    def create(self, vals):
        values = {}
        mail_mail = self.env['mail.mail']
       
        # context: no_log, because subtype already handle this
        result = super(HelpdeskTicket, self.with_context(mail_create_nolog=True)).create(vals)

        values['subject'] = 'ePillars Support Case Created - %s  [%s]' % (result.name,result.id)
        values['body_html'] = """<html>
                                <head></head>
                                <body>    
                                Case Number:	"""+str(result.id) +"""<br/>
                                Support Account Name:	"""+ str(result.partner_id.name)+"""<br/>
                                Support Account Email:	"""+ str(result.partner_email)+"""<br/>
                                Status:	New <br/>
                                Subject:	"""+str(result.name) +"""<br/><br/><br/>


                                You will not be able to 'Reply' to this e-mail. If you wish to contact us,<br/> 
                                Please call +97143263939.
                                </body>
                                </html>
                                """
        values['email_from'] = 'ePillars Support<support@epillars.com>'
        values['email_to'] = result.partner_email
        values['reply_to'] = 'noreply<noreply@epillars.com>'
        if values['email_to']:
            mail= mail_mail.create(values)
        return result

How to add new button box – odoo


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


    @api.multi
    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', '=', self.id)])
        for data in onboard:
            onboard_ids.append(data.id)

        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">
                </button>
            </xpath>
        </field>
    </record>

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>
            </xpath>
        </field>
        </record>