Siirry sisältöön
Menu
Sinun on rekisteröidyttävä, jotta voit olla vuorovaikutuksessa yhteisön kanssa.
Tämä kysymys on merkitty
2 Vastaukset
3551 Näkymät

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
Hylkää
Paras vastaus
Chech below in the comment as odoo is not allowing me to paste HTMl as raw in here










Avatar
Hylkää

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.

Paras vastaus

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
Hylkää

How can apply it but for odoo version 15?

Aiheeseen liittyviä artikkeleita Vastaukset Näkymät Toimenpide
1
toukok. 22
2035
1
heinäk. 25
2056
4
elok. 25
3328
0
maalisk. 25
1331
2
tammik. 25
2479