Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[14.0][IMP]sale_commission_partial_settlement: save settlement wizard date #579

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading