Skip to content

Commit

Permalink
Merge PR #579 into 14.0
Browse files Browse the repository at this point in the history
Signed-off-by PicchiSeba
  • Loading branch information
OCA-git-bot committed Nov 19, 2024
2 parents bfd6ea4 + 33de85a commit b056ceb
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 2 deletions.
2 changes: 2 additions & 0 deletions sale_commission_partial_settlement/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"website": "https://github.com/OCA/commission",
"data": [
"security/ir.model.access.csv",
"views/res_config_settings_view.xml",
"views/sale_commission_settlement_view.xml",
"views/sale_commission_view.xml",
],
"installable": True,
Expand Down
2 changes: 2 additions & 0 deletions sale_commission_partial_settlement/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from . import account_invoice_line_agent
from . import account_invoice_line_agent_partial
from . import account_partial_reconcile
from . import res_company
from . import res_config_settings
from . import sale_commission
from . import sale_commission_settlement
from . import sale_commission_settlement_line
9 changes: 9 additions & 0 deletions sale_commission_partial_settlement/models/res_company.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from odoo import fields, models


class ResCompany(models.Model):
_inherit = "res.company"

commission_show_settlement_dates = fields.Boolean(
"Show invoice and payment dates in settlements",
)
10 changes: 10 additions & 0 deletions sale_commission_partial_settlement/models/res_config_settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from odoo import fields, models


class ResConfigSettings(models.TransientModel):
_inherit = "res.config.settings"

commission_show_settlement_dates = fields.Boolean(
related="company_id.commission_show_settlement_dates",
readonly=False,
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
from odoo import models
from odoo import fields, models


class Settlement(models.Model):
class SaleCommissionSettlement(models.Model):
_inherit = "sale.commission.settlement"

show_settlement_dates = fields.Boolean(
related="company_id.commission_show_settlement_dates"
)
settlement_date_to = fields.Date(
readonly=True,
string="Invoice date up to",
help="The invoice date used to create the settlement",
)
settlement_date_payment_to = fields.Date(
readonly=True,
string="Payment date up to",
help="The payment date used to create the settlement",
)

def unlink(self):
self.mapped("line_ids.agent_line_partial_ids").unlink()
return super().unlink()
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<odoo>
<record id="res_config_settings_view_form" model="ir.ui.view">
<field name="name">res.config.settings.view.form.inherit.sale.management</field>
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="sale_management.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath
expr="//div[@name='quotation_order_setting_container']"
position="inside"
>
<div
class="col-12 col-lg-6 o_setting_box"
id="commission_show_settlement_dates"
>
<div class="o_setting_left_pane">
<field name="commission_show_settlement_dates" />
</div>
<div class="o_setting_right_pane">
<label for="commission_show_settlement_dates" />
<span
class="fa fa-lg fa-building-o"
title="Values set here are company-specific."
groups="base.group_multi_company"
/>
<div class="text-muted">
Shows the dates used to create the settlement itself
</div>
</div>
</div>
</xpath>
</field>
</record>
</odoo>
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<record id="view_settlement_form" model="ir.ui.view">
<field name="name">Settlements</field>
<field name="model">sale.commission.settlement</field>
<field name="inherit_id" ref="sale_commission.view_settlement_form" />
<field name="arch" type="xml">
<xpath expr="//group[field[@name='date_to']]" position="after">
<group attrs="{'invisible': [('show_settlement_dates', '=', False)]}">
<field name="show_settlement_dates" invisible="1" />
<field name="settlement_date_to" />
<field name="settlement_date_payment_to" />
<field name="create_date" />
</group>
</xpath>
</field>
</record>
</odoo>
10 changes: 10 additions & 0 deletions sale_commission_partial_settlement/wizard/wizard_settle.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@
class SaleCommissionMakeSettle(models.TransientModel):
_inherit = "sale.commission.make.settle"

def _prepare_settlement_vals(self, agent, company, sett_from, sett_to):
vals = super()._prepare_settlement_vals(agent, company, sett_from, sett_to)
vals.update(
{
"settlement_date_to": self.date_to,
"settlement_date_payment_to": self.date_payment_to,
}
)
return vals

def action_settle(self):
partial_res = self.action_settle_partial()
res = super().action_settle()
Expand Down

0 comments on commit b056ceb

Please sign in to comment.