Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
2 Trả lời
3571 Lượt xem

I'm having problems to add the fields to PartnerDetailsEdit screen, this are the models that i'm using:

classDepartamento(models.Model):

_name = 'departamentos'
name = fields.Char(string='Nombre')codigo = fields.Char(string='Código')
municipios_ids = fields.One2many('municipios', 'departamentos_id', string='Municipios')

classMunicipio(models.Model):

_name = 'municipios'
name = fields.Char(string='Nombre')codigo = fields.Char(string='Código')
departamentos_id = fields.Many2one('departamentos', string='Departamentos')

classResPartner(models.Model)

:_inherit = 'res.partner'

cedula_root = fields.Char(string='cedula', size=10, help='D.U.I del cliente') departamentos_id = fields.Many2one('departamentos', string='Departamento')

municipios_id = fields.Many2one('municipios', string='Municipio', 

domain="[('departamentos_id', '=', departamentos_id)]")


Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất
Chech below in the comment as odoo is not allowing me to paste HTMl as raw in here










Ảnh đại diện
Huỷ bỏ

Hey ,

You have to inherit this qweb template with your field name

<!--<t t-name="PartnerDetailsEdit" t-inherit="point_of_sale.PartnerDetailsEdit" t-inherit-mode="extension" owl="1">-->
<!--<xpath expr="//div[hasclass('partner-details-right')]" position="inside">-->
<!-- <div class="partner-detail">-->
<!-- <span class="label">Your Field</span>-->
<!-- <input class="detail" name="yourfield"-->
<!-- t-on-change="captureChange" t-att-value="props.partner.yourfield || ''"-->
<!-- placeholder="yourfield"/>-->
<!-- </div>-->
<!--</xpath>-->
<!--</t>-->

Also in the .py side you need to add this for your field.

class PosSession(models.Model):
_inherit = 'pos.session'

def _loader_params_res_partner(self):
result = super()._loader_params_res_partner()
if "any condition":
result['search_params']['fields'].append('your_field')
return result

The field will be added to the form .

Thanks.

Câu trả lời hay nhất

Hi,

For those fields in res. partner model, you can use this code

<t t-name="ClientDetailsEdit" t-inherit="point_of_sale.PartnerDetailsEdit" t-inherit-mode="extension" owl="1">
<xpath expr="//input[hasclass('partner-name')]" position="after">
<div class='client-details-right mb-3' style="font-size: initial;">
<t t-esc='props.partner.cedula_root'/>
<t t-esc='props.partner.departamentos_id.name'/>
<t t-esc='props.partner.municipios_id.name'/>
</div>
</xpath>
</t>
 

Regards

Ảnh đại diện
Huỷ bỏ

How can apply it but for odoo version 15?

Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 5 22
2044
1
thg 7 25
2095
4
thg 8 25
3377
0
thg 3 25
1345
2
thg 1 25
2515