跳至内容
菜单
此问题已终结
1 回复
3740 查看

Hello, I have a function that should validate that a product is of type ' Service' . When this condition is met the ' sequence' field must increase its value sequentially.  This method is written in the sale.order.line model.

Please if this function is badly implemented , tell me I can do to correct it.

I hope tips and suggestions thank you very much. Thanks

@api.depends('product_id.product_tmpl_id.type')

def _niu_validation(self):

    if product_id.product_tmpl_id.type == 'service':

          sequence= self.env['ir.sequence'].next_by_code('sale.order.line')

    return super(SaleOrderLine,self)

形象
丢弃
最佳答案

@Charlie

No return is needed from that function and you should use self.product_id if you call it that function using a recordset(also take care of multiple records in the recorset like iterate over self) or pass the product_id to the function if you call the function directly, like:

@api.depends('product_id.product_tmpl_id.type')
def _niu_validation(self, product_id):
    if product_id.type == 'service':
          sequence= self.env['ir.sequence'].next_by_code('sale.order.line')
形象
丢弃
相关帖文 回复 查看 活动
0
2月 16
3752
1
2月 16
3570
0
11月 18
6052
0
9月 20
3642
1
12月 19
17915