Skip to Content
Menu
This question has been flagged
1 Odpoveď
821 Zobrazenia



from odoo import models, fields, api

class Partner(models.Model):    _inherit = 'res.partner'

    customer_code = fields.Char(string="Customer Code", required=True)    branch_id = fields.Many2one("res.branch", string='Branch', store=True)    customer_type_id = fields.Many2one('customer.type', string='Customer Type')    kode_toko = fields.Char(string="Kode Toko")        @api.model_create_multi    def _format_customer_code(self, vals_list):        for vals in vals_list:            if vals.get('customer_code') and not vals.get('customer_code').startswith('['):                vals['customer_code'] = f"[{vals.get('customer_code')}]"        return super(Partner, self)._model_create_multi(vals_list)

    @api.onchange('customer_code')    def _onchange_customer_code(self):        if self.customer_code and not self.customer_code.startswith('['):            self.customer_code = f"[{self.customer_code}]"   



<record id="view_partner_kanban_inherit" model="ir.ui.view">        <field name="name">res.partner.kanban.inherit</field>        <field name="model">res.partner</field>        <field name="inherit_id" ref="base.res_partner_kanban_view"/>         <field name="arch" type="xml">            <xpath expr="//div[@class='oe_kanban_details d-flex flex-column']//strong//field[@name='display_name']" position="before">                <span>                    <t t-if="record.type.raw_value == 'delivery'">                        <field name="kode_toko"/>                    </t>                     <t t-if="record.type.raw_value != 'delivery' and !record.kode_toko.raw_value">                        <field name="customer_code"/>                    </t>                    <t t-if="record.type.raw_value == ['contact', 'private', 'other', 'invoice']">                        <field name="customer_code"/>                    </t>                    <span> - </span>                 </span>            </xpath>        </field>    </record>

from odoo import models, fields, api

class Partner(models.Model):    _inherit = 'res.partner'

    customer_code = fields.Char(string="Customer Code", required=True)    branch_id = fields.Many2one("res.branch", string='Branch', store=True)    customer_type_id = fields.Many2one('customer.type', string='Customer Type')    kode_toko = fields.Char(string="Kode Toko")        @api.model_create_multi    def _format_customer_code(self, vals_list):        for vals in vals_list:            if vals.get('customer_code') and not vals.get('customer_code').startswith('['):                vals['customer_code'] = f"[{vals.get('customer_code')}]"        return super(Partner, self)._model_create_multi(vals_list)

    @api.onchange('customer_code')    def _onchange_customer_code(self):        if self.customer_code and not self.customer_code.startswith('['):            self.customer_code = f"[{self.customer_code}]"   




I want to add code like the company format [...] before the company name. Apart from the delivery address type, the customer_code appears. only other than the 'delivery address' not yet. I have included the models and views. Can anyone help me...

Avatar
Zrušiť
Best Answer

Hi,
Are you looking to generate an automatic reference for the contacts ? if yes, you can create a sequence record and using automated action or by inheriting the create method, you can achieve this.

And there are lot of third party apps in the app store, which provides this functionality, so you can refer to that also.

Thanks

Avatar
Zrušiť
Related Posts Replies Zobrazenia Aktivita
0
sep 24
1108
1
jún 24
1449
1
máj 24
1670
3
máj 24
1869
2
okt 23
5675