Search code examples
python-2.7odoo-9

How can i modify field mask to satisfy a mask which has number of caracter not fixe?


I'm using odoo 9 and i create a field mask on partner code TVA and it works, but my problem is the structure of the code tva sometimes like "9999999 A/A/A/999" and sometimes like "999999 A/A/A/999". The difference is somtimes 7 integer caracters then an alphabetique caracter and sometimes 6 integer caracters. In general the first serial is not always fix and the widget "mask" allowed me to create fixed mask . How can i modify my mask to satisfy my needs . Any idea for help ?

partner_view.xml

 <?xml version="1.0" encoding="utf-8"?>
<openerp>
<data>
   <record id="res_partner_view_purchase_buttons_TVA_RC" model="ir.ui.view">
        <field name="name">num.TVA.RC.res.partner.view.purchase.</field>
        <field name="model">res.partner</field>
        <field name="inherit_id" ref="base.view_partner_form"/>
        <field name="arch" type="xml">
            <xpath expr="//field[@name='website']" position="after">
                        <field name="CodeTVA" select="1" placeholder="Code TVA" widget="mask" mask="999999  A/A/A/999" />
                        <field name="RC" select="1" placeholder="Num RC"/>
            </xpath>
        </field>
   </record>
</data>


Solution

  • Change your mask to specify that you need six or seven digits at the begining:

    mask="9{6,7}  A/A/A/999"