コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
813 ビュー



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

アバター
破棄
最善の回答

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

アバター
破棄
関連投稿 返信 ビュー 活動
0
9月 24
1104
1
6月 24
1448
1
5月 24
1667
3
5月 24
1865
2
10月 23
5671