Ir al contenido
Menú
Se marcó esta pregunta

Hi all, I'm new to Odoo and tried to produce my first module… 

It is -sort of- working but not completely ! 

My problem is that I create a new field "iban_qr_number" but I need to turn "developer mode" to see my field.

I declared my field like this:

from odoo import models, fields
class ResCompany(models.Model):
_inherit = 'res.company'
iban_qr_number = fields.Many2one('res.partner.bank', domain="[('partner_id','=', partner_id)]",)

and create extend res_company_form:

<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="res_company_form" model="ir.ui.view">
<field name="name">res.company.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='currency_id']" position="after">
<field name="iban_qr_number" string="IBAN QR Code on Invoice" placeholder="FR7630004000031234567890143" groups="base.group_no_one"/>
</xpath>
</field>
</record>
</odoo>

I added groups="base.group_no_one" because otherwise I hit an error saying that partner_id is only available for base.group_no_one

Obviously it is not what I want, I'd like to have the same access rights as res_company_form, if user can edit it, he can edit iban_qr_number.


Thank you for your help


Avatar
Descartar
Mejor respuesta

Hi,

Your field will be visible in developer mode because of the groups="base.group_no_one" added in XML for that field. 

Try to remove the group and the domain [('partner_id','=', partner_id)] from the field iban_qr_number and see if the field appears when developer mode is deactivated.

Thanks

Avatar
Descartar
Autor Mejor respuesta

Dear Savya,

Thank you for your answer, 

Try to remove the group and the domain [('partner_id','=', partner_id)] from the field iban_qr_number

If I remove partner_id in the model and the group in the view I hit this error

Le champ 'partner_id' utilisé dans domain of field 'iban_qr_number' ([('partner_id','=', partner_id)]) et limité au ou aux groupes base.group_no_one.

View error context:
{'file': '/tmp/odoo/addons/iban_on_invoice_module/views/res_company_view.xml',
 'line': 1,
 'name': 'res.company.form',
 'view': ir.ui.view(1664,),
 'view.model': 'res.company',
 'view.parent': ir.ui.view(112,),
 'xmlid': 'res_company_form'}

That's why I added the group_no_one

Avatar
Descartar

Okay, so either you can remove the domain from the field and check if the error exists or add an invisible field iban_qr_number with the group no one after the existing field.

Autor

Thanks Savya, removing the domain and the group solve it
now my field is:
iban_qr_number = fields.Many2one('res.partner.bank')
and view is
<field name="iban_qr_number" string="IBAN QR Code on Invoice" placeholder="FR7630004000031234567890143"/>

Publicaciones relacionadas Respuestas Vistas Actividad
1
abr 23
423
0
oct 23
784
1
sept 23
1734
2
mar 15
4107
0
mar 15
3176