コンテンツへスキップ
メニュー
この質問にフラグが付けられました
1 返信
2164 ビュー

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

関連投稿 返信 ビュー 活動
1
1月 24
2175
1
12月 22
2994
5
9月 25
21273
3
8月 25
3049
1
5月 25
2939