Hello. is there any way of making Many2many field related to the Many2one field?
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
- CRM
- e-Commerce
- Accounting
- Inventory
- PoS
- Project management
- MRP
This question has been flagged
Hi,
Consider the following example,in which i am added a Many2many field in Purchase module which shows Sale Orders of particular partner selected from a Many2one field
class PurchaseOrder(models.Model):
_inherit = 'purchase.order'
sale_order_ids = fields.Many2many('sale.order')
Then, we need to set up domain for that Many2many field for showing Sale Orders of selected partner.
@api.onchange('partner_id')
def _on_change_partner_id(self):
print(self.partner_id)
return {'domain': {'sale_order_ids': [('partner_id', '=', self.partner_id.id)]}}
Hope it will work for you.
Hello
you can add m2o filed like
name_field_id= fields.Many2one(string='Field Name', comodel_name='model name', ondelete='restrict')
then add related field like:
field_ids = fields.Many2many(string="Name",related=" name_field_id.field_name")
field_name is name in your model(comodel_name), and must be m2m.
Enjoying the discussion? Don't just read, join in!
Create an account today to enjoy exclusive features and engage with our awesome community!
Sign up