On 23/11/12 21:39 -0800, Ivan Garcia wrote:
> Hello,
>
> some of our reports need to print the Nationality value of a Party based on
> his country, and instead of doing a separate entity with the 'code' field
> related I was thinking if it woudn't be better idea to have an extra column.
>
> this is my nationality.xml
> ------------------------------------------
> <data>
> <record model="country.country" id="af">
> <field name="nationality">Afghan</field>
> <field name="code">AF</field>
> </record>
>
> <record model="country.country" id="ax">
> <field name="nationality">Ålandic</field>
> <field name="code">AX</field>
> </record>
>
> <!-- etc -->
>
> </data>
> --------------------------------------
> and my nationality.py
> ----------------------------------
> from trytond.model import ModelView, ModelSQL, fields
>
> __all__ = ['Nationality']
>
> #Nationality()
> class Nationality(ModelSQL, ModelView):
> "Nationality"
> __name__ = "country.country"
> __description__ = __doc__
>
> nationality = fields.Char('Nationality', required=True)
> #country = fields.One2One('country.country', 'Country',
> # required=True, select=True)
>
> @classmethod
> def __setup__(cls):
> super(Nationality, cls).__setup__()
>
> -------------------------
>
> but when I init the module:
> trytond -c trytond.conf -d tryton --update=country_nationality -v
>
> I get this following error:
> File
> "/home/ivan/workspace/tryton26/env/lib/python2.7/site-packages/trytond/error.py",
>
> line 70, in raise_user_error
> raise UserError(error)
> trytond.exceptions.UserError: ('UserError', (u'The field "Name" on
> "Country" is required.', ''))
>
> So... what am I doing wrong? am I missing some extra statement to add the
> column into the existing Country table?
With the XML you wrote, you don't update the existing record by create a
new one. You must prefix the XML id with the module name like this:
<data>
<record model="country.country" id="country.af">
<field name="nationality">Afghan</field>
</record>
<record model="country.country" id="country.ax">
<field name="nationality">Ålandic</field>
</record>
…
</data>
--
Cédric Krier
B2CK SPRL
Rue de Rotterdam, 4
4000 Liège
Belgium
Tel: +32 472 54 46 59
Email/Jabber: [email protected]
Website: http://www.b2ck.com/
pgpe55TXZPJRb.pgp
Description: PGP signature
