Hi,
To achieve this, you can create a wizard that will be triggered when a design is selected in the Sale Order line.
By adding the following code in your sale order model it will return a wizard that you created:@api.onchange('product_id')
def _onchange_product_id(self):
if self.product_id.design:
return {
'name': 'Design Details',
'view_mode': 'form',
'res_model': 'sale.order.design.wizard',
'target': 'new',
'type': 'ir.actions.act_window',
'context': {'default_sale_order_line_id': self.id},
}
For checking constraints use the following code:
@api.constrains('design_field_1', 'design_field_2')
def _check_design_fields(self):
for line in self:
if line.product_id.design and (not line.design_field_1 or not line.design_field_2):
raise ValidationError('You must fill in all design fields for the selected design.')
For creating wizard, go through the link below mentioned:
https://www.cybrosys.com/blog/how-to-create-and-manage-wizard-in-odoo-17
Hope it helps.