From 3b1ef1fb83d1c4e77e18146b721d65b79e0b14c3 Mon Sep 17 00:00:00 2001 From: Alessandro Uffreduzzi Date: Wed, 13 Nov 2024 16:42:37 +0100 Subject: [PATCH] [IMP]sale_commission: save settlement wizard date in settlement --- sale_commission/__manifest__.py | 1 + sale_commission/models/__init__.py | 2 ++ sale_commission/models/res_company.py | 9 +++++ sale_commission/models/res_config_settings.py | 10 ++++++ sale_commission/models/settlement.py | 13 +++++++ .../views/res_config_settings_view.xml | 34 +++++++++++++++++++ .../views/sale_commission_settlement_view.xml | 8 +++++ sale_commission/wizard/wizard_settle.py | 2 ++ 8 files changed, 79 insertions(+) create mode 100644 sale_commission/models/res_company.py create mode 100644 sale_commission/models/res_config_settings.py create mode 100644 sale_commission/views/res_config_settings_view.xml diff --git a/sale_commission/__manifest__.py b/sale_commission/__manifest__.py index 534bef4b3..53562a306 100644 --- a/sale_commission/__manifest__.py +++ b/sale_commission/__manifest__.py @@ -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", diff --git a/sale_commission/models/__init__.py b/sale_commission/models/__init__.py index 3947c2579..6fd7de9c8 100644 --- a/sale_commission/models/__init__.py +++ b/sale_commission/models/__init__.py @@ -6,3 +6,5 @@ from . import res_partner from . import sale_order from . import settlement +from . import res_company +from . import res_config_settings diff --git a/sale_commission/models/res_company.py b/sale_commission/models/res_company.py new file mode 100644 index 000000000..ad0c7e5a5 --- /dev/null +++ b/sale_commission/models/res_company.py @@ -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", + ) diff --git a/sale_commission/models/res_config_settings.py b/sale_commission/models/res_config_settings.py new file mode 100644 index 000000000..74f38e47a --- /dev/null +++ b/sale_commission/models/res_config_settings.py @@ -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, + ) diff --git a/sale_commission/models/settlement.py b/sale_commission/models/settlement.py index adcb0d94d..bbde4650d 100644 --- a/sale_commission/models/settlement.py +++ b/sale_commission/models/settlement.py @@ -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): diff --git a/sale_commission/views/res_config_settings_view.xml b/sale_commission/views/res_config_settings_view.xml new file mode 100644 index 000000000..ad872ddcf --- /dev/null +++ b/sale_commission/views/res_config_settings_view.xml @@ -0,0 +1,34 @@ + + + + res.config.settings.view.form.inherit.sale.management + res.config.settings + + + +
+
+ +
+
+
+
+
+
+
+
diff --git a/sale_commission/views/sale_commission_settlement_view.xml b/sale_commission/views/sale_commission_settlement_view.xml index 00fe202cf..4a2ddf536 100644 --- a/sale_commission/views/sale_commission_settlement_view.xml +++ b/sale_commission/views/sale_commission_settlement_view.xml @@ -84,6 +84,14 @@ + + + + + + diff --git a/sale_commission/wizard/wizard_settle.py b/sale_commission/wizard/wizard_settle.py index 4970b8b06..b128febf8 100644 --- a/sale_commission/wizard/wizard_settle.py +++ b/sale_commission/wizard/wizard_settle.py @@ -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):