[IMP] hr_commission: extended ahead of timesheet based commission

* Allow invoice to see commission it is deriving amount for. This allows for basing on amounts that may depend on the employee or contract config.
* Prevent making commissions if the employee rate or admin rates are not set.
* Updated views to work in both CE and EE
This commit is contained in:
Jared Kipe
2022-02-01 14:08:06 -08:00
parent d11f196592
commit 9b0278002c
3 changed files with 27 additions and 14 deletions

View File

@@ -36,7 +36,7 @@ class AccountMove(models.Model):
self.env['hr.commission'].invoice_paid(self)
return res
def amount_for_commission(self):
def amount_for_commission(self, commission=None):
if hasattr(self, 'margin') and self.company_id.commission_amount_type == 'on_invoice_margin':
sign = -1 if self.move_type in ['in_refund', 'out_refund'] else 1
return self.margin * sign