Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odgovori
1791 Prikazi

i want to get help from seniors here. i have created 3 models 1 parent 2 child, please see below for one2many fields i used here, is it correct or anything i have to modify and have some standard of Odoo. removed some fields to minimize the code to mention here. seeking guide and expert opinion.


class DoneeRegister(models.Model):

_name = 'donee.register

_description = 'Donee Registration'


name = fields.Char(string='Donee Name')

donee_type_id = fields.Many2one('donee.types', string='Type')

contact_no = fields.Char(string='Mobile No.')

address = fields.Char(string='Address')

is_active = fields.Boolean(string='Active?')

donee_ids = fields.One2many('donee\\\.family\\\.members',\\\ 'donee_id',\\\ string="Donee\\\ Family"\\\)

donee_rel_ids\\\ =\\\ fields\\\.One2many\\\('donee\\\.relatives',\\\ 'donee_rel_id',string="Donee\\\ Relative"\\\)



class\\\\ DoneeFamily\\\\(models\\\\.Model\\\\):

_name\\\ =\\\ 'donee.family.members'

_description = 'Donee Family Members'


name = fields.Char(string='Family Member Name')

donee_id = fields.Maony2one('donee.register', 'id', string='Donee', ondelete='cascade', required=True)

contact_no = fields.Char(string='Mobile No.')



class DoneeRelatives(models.Model):

_name = 'donee.relatives'

_description = 'Donee Relatives'


name = fields.Char(string='Relative Name')

donee_rel_id = fields.Maony2one('donee.register', 'id', string='Donee', ondelete='cascade', required=True)

contact_no = fields.Char(string='Mobile No.')

address = fields.Char(string='Address')


regards

Avatar
Opusti
Best Answer

Hi,

The `donee_ids` and `donee_rel_ids` fields in the parent class could be made more explicit by providing them with more descriptive names that clearly indicate their purpose or the kind of data they hold. This can improve the readability and maintainability of the code. For example:

- `donee_ids` could be renamed to something like `family_member_ids` based on the context.
- `donee_rel_ids` could be renamed to `relative_ids`.

By choosing more descriptive names, it becomes easier for developers (including yourself) to understand the purpose and usage of these fields when working with the code.

Try:
```python
family_member_ids = fields.One2many('donee.family.members', 'donee_id', string="Family Members")
relative_ids = fields.One2many('donee.relatives', 'donee_rel_id', string="Relatives")

Hope it helps

Avatar
Opusti
Avtor

thanks very much for your inputs and guide.

regards

Related Posts Odgovori Prikazi Aktivnost
1
jan. 24
1776
1
dec. 22
2670
1
maj 25
2155
1
apr. 25
3223
1
apr. 25
4039