콘텐츠로 건너뛰기
메뉴
커뮤니티에 참여하려면 회원 가입을 하시기 바랍니다.
신고된 질문입니다
1 회신
822 화면



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
1108
1
6월 24
1449
1
5월 24
1670
3
5월 24
1869
2
10월 23
5675