как я могу создать заказ на производство прогнозируемого продукта в строке заказа на продажу в odoo v13?

Class SaleOrder (models.Model): _inherit = "sale.order"

@api.depends('order_line.price_total')
def _amount_all(self):
    for order in self:
        for line in order.order_line:
            if line.product_id.id != False:
                pass
            elif line.bom_id.id == False:
                raise ValidationError(("Bill Of Material is required!!!"))
            else:
                if line.bom_id.product_tmpl_id.name != line.product_id.name:
                    raise ValidationError(("Sale order's and Bill of Material's Product must be same!!!"))

    return super(SaleOrder,self)._amount_all()



def action_confirm(self):
    for record in self:
        for rec in record.order_line:
            if rec.bom_id.id == False:
                raise ValidationError(("Bill Of Material is required!!!"))
            else:
                if rec.bom_id.product_tmpl_id.name != rec.product_id.name:
                    raise ValidationError(("Sale order's and Bill of Material's Product must be same!!!"))

    return super(SaleOrder,self).action_confirm()

class SaleOrderLine(models.Model): _inherit = "sale.order.line"

bom_id = fields.Many2one("mrp.bom",string="Bill Of Material")

класс MrpBom(models.Model): _inherit = 'mrp.bom'

0 ответов

Другие вопросы по тегам