Skip to Content
Menu
Musisz się zarejestrować, aby móc wchodzić w interakcje z tą społecznością.
To pytanie dostało ostrzeżenie
1 Odpowiedz
1935 Widoki

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

Awatar
Odrzuć
Najlepsza odpowiedź

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

Awatar
Odrzuć
Autor

thanks very much for your inputs and guide.

regards

Powiązane posty Odpowiedzi Widoki Czynność
1
sty 24
1974
1
gru 22
2808
3
sie 25
2541
1
maj 25
2598
1
kwi 25
3571