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: save settlement wizard date in settlement #578

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions sale_commission/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"views/sale_commission_settlement_view.xml",
"views/sale_commission_settlement_report.xml",
"views/report_settlement_templates.xml",
"views/res_config_settings_view.xml",
"report/sale_commission_analysis_report_view.xml",
"wizard/wizard_settle.xml",
"wizard/wizard_invoice.xml",
Expand Down
2 changes: 2 additions & 0 deletions sale_commission/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
from . import res_partner
from . import sale_order
from . import settlement
from . import res_company
from . import res_config_settings
9 changes: 9 additions & 0 deletions sale_commission/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/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,
)
13 changes: 13 additions & 0 deletions sale_commission/models/settlement.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,19 @@ def _default_currency(self):
default=lambda self: self.env.user.company_id,
required=True,
)
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",
)

@api.depends("line_ids", "line_ids.settled_amount")
def _compute_total(self):
Expand Down
34 changes: 34 additions & 0 deletions sale_commission/views/res_config_settings_view.xml
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>
8 changes: 8 additions & 0 deletions sale_commission/views/sale_commission_settlement_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@
<field name="currency_id" invisible="1" />
<field name="agent_type" invisible="1" />
</group>
<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>
</group>
<group string="Commission lines" colspan="4">
<field name="line_ids" nolabel="1">
Expand Down
2 changes: 2 additions & 0 deletions sale_commission/wizard/wizard_settle.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def _prepare_settlement_vals(self, agent, company, sett_from, sett_to):
"date_from": sett_from,
"date_to": sett_to,
"company_id": company.id,
"settlement_date_to": self.date_to,
"settlement_date_payment_to": self.date_payment_to,
}

def action_settle(self):
Expand Down
Loading