Перейти к содержимому
Меню
Чтобы взаимодействовать с сообществом, необходимо зарегистрироваться.
Этот вопрос был отмечен
1 Ответить
1785 Представления

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

Аватар
Отменить
Лучший ответ

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

Аватар
Отменить
Автор

thanks very much for your inputs and guide.

regards

Related Posts Ответы Просмотры Активность
1
янв. 24
1766
1
дек. 22
2660
1
мая 25
2133
1
апр. 25
3212
1
апр. 25
4023