[IMP] commission_simple: add total base amount in view and XLSX report
This commit is contained in:
@@ -32,7 +32,10 @@ class CommissionResult(models.Model):
|
|||||||
states={'done': [('readonly', True)]})
|
states={'done': [('readonly', True)]})
|
||||||
amount_total = fields.Monetary(
|
amount_total = fields.Monetary(
|
||||||
string='Commission Total', currency_field='company_currency_id',
|
string='Commission Total', currency_field='company_currency_id',
|
||||||
compute='_compute_amount_total', store=True, tracking=True)
|
compute='_compute_totals', store=True, tracking=True)
|
||||||
|
base_total = fields.Monetary(
|
||||||
|
string="Commission Base Total", currency_field='company_currency_id',
|
||||||
|
compute='_compute_totals', store=True, tracking=True)
|
||||||
state = fields.Selection([
|
state = fields.Selection([
|
||||||
('draft', 'Draft'),
|
('draft', 'Draft'),
|
||||||
('done', 'Done'),
|
('done', 'Done'),
|
||||||
@@ -44,12 +47,13 @@ class CommissionResult(models.Model):
|
|||||||
def _assign_type_selection(self):
|
def _assign_type_selection(self):
|
||||||
return self.env['commission.profile.assignment']._assign_type_selection()
|
return self.env['commission.profile.assignment']._assign_type_selection()
|
||||||
|
|
||||||
@api.depends('line_ids.commission_amount')
|
@api.depends('line_ids.commission_amount', 'line_ids.commission_base')
|
||||||
def _compute_amount_total(self):
|
def _compute_totals(self):
|
||||||
rg_res = self.env['account.move.line'].read_group([('commission_result_id', 'in', self.ids)], ['commission_result_id', 'commission_amount:sum'], ['commission_result_id'])
|
rg_res = self.env['account.move.line'].read_group([('commission_result_id', 'in', self.ids)], ['commission_result_id', 'commission_amount:sum', 'commission_base:sum'], ['commission_result_id'])
|
||||||
mapped_data = dict([(x['commission_result_id'][0], x['commission_amount']) for x in rg_res])
|
mapped_data = dict([(x['commission_result_id'][0], {'amount': x['commission_amount'], 'base': x['commission_base']}) for x in rg_res])
|
||||||
for rec in self:
|
for rec in self:
|
||||||
rec.amount_total = mapped_data.get(rec.id, 0)
|
rec.amount_total = mapped_data.get(rec.id, {}).get('amount')
|
||||||
|
rec.base_total = mapped_data.get(rec.id, {}).get('base')
|
||||||
|
|
||||||
def unlink(self):
|
def unlink(self):
|
||||||
for result in self:
|
for result in self:
|
||||||
|
|||||||
@@ -34,7 +34,10 @@ class CommissionResultXlsx(models.AbstractModel):
|
|||||||
sheet.write(i, 0, _('Currency'), styles['subtitle'])
|
sheet.write(i, 0, _('Currency'), styles['subtitle'])
|
||||||
sheet.write(i, 1, result.company_id.currency_id.name, styles['subtitle'])
|
sheet.write(i, 1, result.company_id.currency_id.name, styles['subtitle'])
|
||||||
i += 1
|
i += 1
|
||||||
sheet.write(i, 0, _('Total Amount'), styles['subtitle'])
|
sheet.write(i, 0, _('Base Total'), styles['subtitle'])
|
||||||
|
sheet.write(i, 1, result.base_total, styles['subtitle_amount'])
|
||||||
|
i += 1
|
||||||
|
sheet.write(i, 0, _('Amount Total'), styles['subtitle'])
|
||||||
sheet.write(i, 1, result.amount_total, styles['subtitle_amount'])
|
sheet.write(i, 1, result.amount_total, styles['subtitle_amount'])
|
||||||
i += 3
|
i += 3
|
||||||
cols = self._prepare_xlsx_cols()
|
cols = self._prepare_xlsx_cols()
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
<field name="date_range_id"/>
|
<field name="date_range_id"/>
|
||||||
<field name="date_start"/>
|
<field name="date_start"/>
|
||||||
<field name="date_end"/>
|
<field name="date_end"/>
|
||||||
|
<field name="base_total"/>
|
||||||
<field name="amount_total"/>
|
<field name="amount_total"/>
|
||||||
<field name="company_currency_id" invisible="1"/>
|
<field name="company_currency_id" invisible="1"/>
|
||||||
<field name="company_id" invisible="1"/>
|
<field name="company_id" invisible="1"/>
|
||||||
@@ -48,7 +49,7 @@
|
|||||||
<field name="price_unit" string="Price" optional="hide"/>
|
<field name="price_unit" string="Price" optional="hide"/>
|
||||||
<field name="discount" string="Disc.%" optional="hide"/>
|
<field name="discount" string="Disc.%" optional="hide"/>
|
||||||
<field name="price_subtotal" optional="hide" string="Invoiced Amount"/>
|
<field name="price_subtotal" optional="hide" string="Invoiced Amount"/>
|
||||||
<field name="commission_base"/>
|
<field name="commission_base" sum="1"/>
|
||||||
<field name="commission_rate" string="Rate (%)"/>
|
<field name="commission_rate" string="Rate (%)"/>
|
||||||
<field name="commission_amount" sum="1"/>
|
<field name="commission_amount" sum="1"/>
|
||||||
<field name="commission_rule_id" optional="hide"/>
|
<field name="commission_rule_id" optional="hide"/>
|
||||||
@@ -79,6 +80,7 @@
|
|||||||
<field name="assign_type" optional="hide" widget="badge" decoration-warning="assign_type == 'user'"/>
|
<field name="assign_type" optional="hide" widget="badge" decoration-warning="assign_type == 'user'"/>
|
||||||
<field name="company_currency_id" invisible="1"/>
|
<field name="company_currency_id" invisible="1"/>
|
||||||
<field name="company_id" groups="base.group_multi_company"/>
|
<field name="company_id" groups="base.group_multi_company"/>
|
||||||
|
<field name="base_total" sum="1" optional="hide"/>
|
||||||
<field name="amount_total" sum="1" optional="show"/>
|
<field name="amount_total" sum="1" optional="show"/>
|
||||||
<field name="state" decoration-info="state == 'draft'" decoration-success="state == 'done'" widget="badge"/>
|
<field name="state" decoration-info="state == 'draft'" decoration-success="state == 'done'" widget="badge"/>
|
||||||
</tree>
|
</tree>
|
||||||
|
|||||||
Reference in New Issue
Block a user