class SalesmanCommission(models.Model):
_name = 'salesman.commission'
_rec_name = 'partner_id'
@api.depends('commission_line.commission')
def _compute_commission(self):
for rec in self:
# return '250'
rec.update({'commission': sum(rec.commission_line.mapped('commission'))})
print self.commission
partner_id = fields.Many2one('res.users', string='SalesMan')
commission_line = fields.One2many('salesman.commission.line', 'line_id', 'Commission Line')
commission = fields.Monetary(compute='_compute_commission', string='Commission', readonly=True)
currency_id = fields.Many2one('res.currency', default=lambda self: self.env.user.company_id.currency_id.id)
class SalesmancommissionLine(models.Model):
_name = 'salesman.commission.line'
order_id = fields.Many2one('sale.order', 'Order')
commission = fields.Monetary('Commission')
currency_id = fields.Many2one('res.currency', default=lambda self: self.env.user.company_id.currency_id.id)
date = fields.Date('Date')
line_id = fields.Many2one('salesman.commission', string='Line Id')
<record model="ir.ui.view" id="view_salesman_commission_pivot">
<field name="name">salesman.commission.pivot</field>
<field name="model">salesman.commission</field>
<field name="arch" type="xml">
<pivot string="Salesman Commission Line">
<field name="commission" type="measure"/>
</pivot>
</field>
</record>
while in sale module amount_total is also compute but it is working in pivot
can anyone help, thanks.