方法我想跳过
@api.multi
def write(self, vals):
if 'uom_id' in vals:
new_uom = self.env['product.uom'].browse(vals['uom_id'])
updated = self.filtered(lambda template: template.uom_id != new_uom)
done_moves = self.env['stock.move'].search([('product_id', 'in', updated.mapped('product_variant_ids').ids)], limit=1)
if done_moves:
raise UserError(_("You can not change the unit of measure of a product that has already been used in a done stock move. If you need to change the unit of measure, you may deactivate this product."))
return super(ProductTemplate, self).write(vals)
我想要执行的方法:
@api.multi
def write(self, vals):
if 'uom_id' in vals:
new_uom = self.env['product.uom'].browse(vals['uom_id'])
updated = self.filtered(lambda template: template.uom_id != new_uom)
done_moves = self.env['stock.move'].search([('product_id', 'in', updated.mapped('product_variant_ids').ids)], limit=1)
print("@")
return super(my_product_class, self).write(vals)\
第一个write方法在product.py中,它是一个基类,所以我不能改变它,所以我想执行我正确的方法。怎么做?
答案 0 :(得分:0)
class my_product_class (models.Model):
_inherit="product.template"
@api.multi
def write(self, vals):
print(" ")
return super(**ProductTemplate**, self).write(vals)