Hi, I have a problem on a Many2One field, I'll try to explain it as
plainly as possible. Keep in mind that I'm fairly new to tryton and I
surely miss some key concept...

I'm using 2.2.0 release and have a model with two Many2One fields, for
country.country and country.subdvision (similar situation as
party.address):

----------------------------------------------------------------------------------------------
class TrainingStaff(ModelSQL, ModelView):
    "Training Staff"
    _description = __doc__
    _name = 'train.TrainingStaff'
    ....
    country = fields.Many2One('country.country', 'Birth Country',
        on_change=['country', 'subdivision'])
    subdivision = fields.Many2One("country.subdivision",
            'Birth City', domain=[('country', '=', Eval('country'))],
            depends=['country'],
            context={'country':Eval('country')}
            )
    ....
----------------------------------------------------------------------------------------------

in the xml file i left the default widget for the subdivision field:

----------------------------------------------------------------------------------------------
        <record model="ir.ui.view" id="TrainingStaff_form">
            <field name="model">train.TrainingStaff</field>
            <field name="type">form</field>
            <field name="arch" type="xml">
              <![CDATA[
                <form string="Education Level" col="1">
                    <notebook>
                       -------------------
                        <page string="Birth"
id="TrainingStaff_form_birth" col="2">
                            <label name="country"/>
                            <field name="country" widget="selection"/>
                            <label name="subdivision"/>
                            <field name="subdivision"/>
                        </page>
---------------------------------------------------------------------------------------------------------


when I try to create a new subdvision record from the
TrainingStaff_form_birth page (AFTER the country field has been set
and using the 'Create new record' button on the right of the
subdivision field) the Subdvision form pops up with the Name, Code,
Type and Parent fields. When I fill the fields and click the OK button
i get the error 'The field "Country" on "Subdvision" is required'.
I thought that the context={'country':Eval('country') set on the
May2One subdvision field could get the value of the country field of
the train.TrainingStaff model but evidently it doesn't...what am i
missing?

thanks for any help

-- 
[email protected] mailing list

Reply via email to