This question has been flagged
2 Replies
2188 Views

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)]")


Avatar
Discard
Best Answer
Chech below in the comment as odoo is not allowing me to paste HTMl as raw in here










Avatar
Discard

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.

Best Answer

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

Avatar
Discard

How can apply it but for odoo version 15?