Skip to Content
Meniu
Trebuie să fiți înregistrat pentru a interacționa cu comunitatea.
Această întrebare a fost marcată
1 Răspunde
811 Vizualizări



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...

Imagine profil
Abandonează
Cel mai bun răspuns

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

Imagine profil
Abandonează
Related Posts Răspunsuri Vizualizări Activitate
0
sept. 24
1104
1
iun. 24
1446
1
mai 24
1665
3
mai 24
1865
2
oct. 23
5671