Cap nhat views

This commit is contained in:
mtpc4s9 2025-11-19 21:10:16 +07:00
parent 6accf394c9
commit 4374256c5c
4 changed files with 29 additions and 9 deletions

View File

@ -25,8 +25,6 @@ class ZooAnimal(models.Model):
introduction_vn = fields.Html('Introduction (VI)')
is_purchased = fields.Boolean('Has Been Purchased', default=False)
purchase_price = fields.Float('Purchase Price')
parent_id = fields.Many2one(comodel_name='zoo.animal', string='Parent', ondelete='set null')
male_children_ids = fields.One2many(comodel_name='zoo.animal', inverse_name='parent_id', string='Children')
veterinarian_id = fields.Many2one(comodel_name='res.partner', string='Veterinarian')
# thêm vào cuối:
@ -38,6 +36,10 @@ class ZooAnimal(models.Model):
mother_id = fields.Many2one(comodel_name='zoo.animal', string='Mother', ondelete='set null') # ondelete: 'set null', 'restrict', 'cascade'
mother_name = fields.Char('Mother Name', related='mother_id.name')
female_children_ids = fields.One2many(comodel_name='zoo.animal', inverse_name='mother_id', string='Female Children')
father_id = fields.Many2one(comodel_name='zoo.animal', string='Father', ondelete='set null')
father_name = fields.Char('Father Name', related='father_id.name')
male_children_ids = fields.One2many(comodel_name='zoo.animal', inverse_name='father_id', string='Male Children')
toy_ids = fields.Many2many(comodel_name='product.product',
string="Toys",

View File

@ -23,11 +23,17 @@
<field name="age"/>
<field name="weight"/>
<field name="weight_pound"/>
<field name="nickname"/>
</group>
<group>
<field name="feed_time"/>
<field name="mother_id"/>
<field name="mother_name"/>
<field name="father_id"/>
<field name="father_name"/>
<field name="veterinarian_id"/>
<field name="is_purchased"/>
<field name="purchase_price" attrs="{'invisible': [('is_purchased', '=', False)]}"/>
</group>
</group>
@ -38,6 +44,10 @@
<label for="introduction" colspan="2"/>
<field name="introduction" colspan="2" nolabel="1" widget="html"/>
</group>
<group>
<label for="introduction_vn" colspan="2"/>
<field name="introduction_vn" colspan="2" nolabel="1" widget="html"/>
</group>
<group>
<label for="description" colspan="2"/>
<field name="description" colspan="2" nolabel="1"/>
@ -46,12 +56,15 @@
</page>
<page name="children" string="Children">
<group>
<group>
<label for="female_children_ids" colspan="2"/>
<field name="female_children_ids" colspan="2" nolabel="1" widget="many2many_tags"/>
</group>
<group>
</group>
<field name="number_of_children"/>
</group>
<group>
<label for="female_children_ids" colspan="2"/>
<field name="female_children_ids" colspan="2" nolabel="1"/>
</group>
<group>
<label for="male_children_ids" colspan="2"/>
<field name="male_children_ids" colspan="2" nolabel="1"/>
</group>
</page>
<page name="others" string="Others">
@ -77,11 +90,16 @@
<list string="Animals" default_order="create_date desc">
<field name="image" widget="image" options='{"size": [64, 64]}'/>
<field name="name"/>
<field name="nickname"/>
<field name="creature_id"/>
<field name="dob"/>
<field name="gender"/>
<field name="age"/>
<field name="gender"/>
<field name="weight"/>
<field name="mother_id"/>
<field name="father_id"/>
<field name="is_purchased"/>
<field name="number_of_children"/>
<field name="is_alive"/>
</list>
</field>