我创建了一个取决于销售的新模块。我还在销售订单中创建了销售佣金标签。我想在我的新模型amount_total
中将sale.order
sales_value
添加到commission.sale
,但没有任何反应。
在commission.py中
_name = 'commission.sale'
sales_value = fields.Float(compute="_total", string="Sale Value")
@api.multi
def _total(self):
sale_obj = self.env['sale.order'].search([('amount_total','=', True)])
self.sales_value = self.sale_obj.amount_total
答案 0 :(得分:1)
class salesman_commission(models.Model):
_name = 'salesman_commission'
user = fields.Many2one('res.users',string='User')
sales_order_id = fields.Many2one('sale.order',string='Sale id',ondelete='cascade')
sales_val = fields.Float(compute='_total',string='Sales Value')
percent = fields.Float(string='Percent')
commission = fields.Integer(compute='_commission',string='Commission')
@api.one
@api.depends('sales_order_id.amount_total')
def _total(self):
self.sales_val = self.sales_order_id.amount_total