From a1d3f9e652494c40cc1dc5ca2a9d01428d4cc615 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 5 Apr 2024 10:22:04 +0200 Subject: [PATCH 01/12] [FIX] display correctly the date of the deposit date in the commission wizard and on the invoice line, depending on the lang of the current user or the supplier partner --- ...oint_buying_invoice_commission_wizard_line.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py b/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py index 7429fb63..78dbd0ea 100644 --- a/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py +++ b/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py @@ -50,6 +50,17 @@ class JointbuyingInvoiceCommissionWizardLine(models.TransientModel): string="Detail", compute="_compute_grouped_order_info" ) + def datetime_to_string(self, dt, partner=False): + if not partner or not partner.lang: + partner = self.env.user.partner_id + if not partner or not partner.lang: + partner = self.env.user.company_id.partner_id + lang = self.env["res.lang"].search([("code", "=", partner.lang)]) + date_tz_user = fields.Datetime.context_timestamp( + self, fields.Datetime.from_string(dt) + ) + return date_tz_user.strftime(lang.date_format) + @api.depends("wizard_id.max_deposit_date", "partner_id") def _compute_grouped_order_info(self): for line in self: @@ -63,7 +74,7 @@ def _compute_grouped_order_info(self): ) line.grouped_order_detail = "\n".join( [ - f"- {x['name']} - {x['deposit_date'].strftime('%m/%d/%Y')}" + f"- {x['name']} - {self.datetime_to_string(x['deposit_date'])}" f" - {x['amount_untaxed']:.2f} €" for x in all_data ] @@ -166,6 +177,7 @@ def _prepare_invoice_line(self, invoice, grouped_order): and x.amount_untaxed != 0.0 ) base = sum(valid_orders.mapped("amount_untaxed")) + description = _( "Commission on %s deposited on %s\n" "- Ordered Amount : %.2f €\n" @@ -173,7 +185,7 @@ def _prepare_invoice_line(self, invoice, grouped_order): "- Rate : %.2f %%" ) % ( grouped_order.name, - grouped_order.deposit_date.strftime("%m/%d/%Y"), + self.datetime_to_string(grouped_order.deposit_date, self.local_partner_id), base, len(valid_orders), "-".join(valid_orders.mapped("customer_id.joint_buying_code")), From 8a31ab654c4c9be5c7bac7b5cac6616fd01d40d0 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 5 Apr 2024 10:35:56 +0200 Subject: [PATCH 02/12] [IMP] Add filter and groupby option on joint.buying.tour search view --- joint_buying_base/views/view_joint_buying_tour.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/joint_buying_base/views/view_joint_buying_tour.xml b/joint_buying_base/views/view_joint_buying_tour.xml index 66ee6c69..edba6fb2 100644 --- a/joint_buying_base/views/view_joint_buying_tour.xml +++ b/joint_buying_base/views/view_joint_buying_tour.xml @@ -22,7 +22,10 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + + From 1a4538a1becb0a6c537e4525bd088db856013744 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 5 Apr 2024 10:46:22 +0200 Subject: [PATCH 03/12] [IMP] update french translation --- joint_buying_base/i18n/fr.po | 62 ++++++++++-------------------------- 1 file changed, 16 insertions(+), 46 deletions(-) diff --git a/joint_buying_base/i18n/fr.po b/joint_buying_base/i18n/fr.po index 75b1e6ba..d2369814 100644 --- a/joint_buying_base/i18n/fr.po +++ b/joint_buying_base/i18n/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2023-12-13 20:27+0000\n" -"PO-Revision-Date: 2023-12-13 20:27+0000\n" +"POT-Creation-Date: 2024-04-05 08:43+0000\n" +"PO-Revision-Date: 2024-04-05 08:43+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,7 +16,7 @@ msgstr "" "Plural-Forms: \n" #. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:310 +#: code:addons/joint_buying_base/models/joint_buying_tour.py:260 #, python-format msgid "%s (copy)" msgstr "%s (copie)" @@ -32,19 +32,19 @@ msgid "Company Address:" msgstr "Adresse de la société:" #. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:241 +#: code:addons/joint_buying_base/models/joint_buying_tour.py:191 #, python-format msgid "Delivery and pick-up" msgstr "Livraison et retrait" #. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:237 +#: code:addons/joint_buying_base/models/joint_buying_tour.py:187 #, python-format msgid "Truck loading" msgstr "Chargement du camion" #. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:239 +#: code:addons/joint_buying_base/models/joint_buying_tour.py:189 #, python-format msgid "Truck unloading" msgstr "Déchargement du camion" @@ -65,7 +65,7 @@ msgid " ( On " msgstr " ( Dans " #. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:234 +#: code:addons/joint_buying_base/models/joint_buying_tour.py:184 #, python-format msgid "Pause" msgstr "" @@ -262,6 +262,7 @@ msgstr "Annuler" #. module: joint_buying_base #: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_tour__carrier_id #: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_tour_type__carrier_id +#: model_terms:ir.ui.view,arch_db:joint_buying_base.view_joint_buying_tour_search msgid "Carrier" msgstr "Transporteur" @@ -328,11 +329,6 @@ msgstr "Code affiché pour la tournée" msgid "Commission" msgstr "" -#. module: joint_buying_base -#: model_terms:ir.ui.view,arch_db:joint_buying_base.view_res_partner_form -msgid "Commission Agreement" -msgstr "Accord de commission" - #. module: joint_buying_base #: model_terms:ir.ui.view,arch_db:joint_buying_base.view_res_partner_form msgid "Commission Rate" @@ -402,11 +398,6 @@ msgstr "Étiquettes de contact" msgid "Cost" msgstr "Coût" -#. module: joint_buying_base -#: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_tour__cost_chart -msgid "Cost Chart" -msgstr "Graphique des coûts" - #. module: joint_buying_base #: model_terms:ir.ui.view,arch_db:joint_buying_base.view_joint_buying_tour_form msgid "Cost allocation" @@ -459,6 +450,7 @@ msgstr "Devise" #: model:res.company,overdue_msg:joint_buying_base.company_CRB #: model:res.company,overdue_msg:joint_buying_base.company_EDC #: model:res.company,overdue_msg:joint_buying_base.company_ELD +#: model:res.company,overdue_msg:joint_buying_base.company_LOG #: model:res.company,overdue_msg:joint_buying_base.company_LSE #: model:res.company,overdue_msg:joint_buying_base.company_PZI #: model:res.company,overdue_msg:joint_buying_base.company_TOU @@ -524,7 +516,7 @@ msgid "Distance" msgstr "" #. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:133 +#: code:addons/joint_buying_base/models/joint_buying_tour.py:125 #, python-format msgid "Draft Tour" msgstr "Tournée en brouillon" @@ -860,7 +852,7 @@ msgid "Journey" msgstr "Trajet" #. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:229 +#: code:addons/joint_buying_base/models/joint_buying_tour.py:179 #, python-format msgid "Journey from %s to %s" msgstr "Trajet de %s à %s" @@ -1158,23 +1150,12 @@ msgid "Route information is given as an indication only!
\n" msgstr "Les prévisions de trajets sont données à titre indicatif seulement !
\n" " Il peut y avoir des bouchons, des retards, des imprévus, etc..." -#. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:161 -#, python-format -msgid "Salary" -msgstr "Salaire" - #. module: joint_buying_base #: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_tour__salary_cost #: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_tour_line__salary_cost msgid "Salary Cost" msgstr "Coût des salaires" -#. module: joint_buying_base -#: selection:joint.buying.transport.request,request_type:0 -msgid "Sale Order" -msgstr "Commande de vente" - #. module: joint_buying_base #: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_tour_line__sequence #: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_wizard_set_tour_line__sequence @@ -1368,12 +1349,6 @@ msgstr "A calculer" msgid "Today" msgstr "Aujourd'hui" -#. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:163 -#, python-format -msgid "Toll" -msgstr "Péage" - #. module: joint_buying_base #: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_tour__toll_cost msgid "Toll Cost" @@ -1468,6 +1443,7 @@ msgstr "Texte d'arbre" #. module: joint_buying_base #: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_tour__type_id +#: model_terms:ir.ui.view,arch_db:joint_buying_base.view_joint_buying_tour_search msgid "Type" msgstr "" @@ -1529,12 +1505,6 @@ msgstr "Utilisateurs" msgid "Vegetable" msgstr "Légumes" -#. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:162 -#, python-format -msgid "Vehicle" -msgstr "Véhicule" - #. module: joint_buying_base #: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_tour__vehicle_cost #: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_tour_line__vehicle_cost @@ -1573,7 +1543,7 @@ msgid "Wizard" msgstr "Assistant" #. module: joint_buying_base -#: code:addons/joint_buying_base/models/res_partner.py:155 +#: code:addons/joint_buying_base/models/res_partner.py:145 #, python-format msgid "You can not create a customer joint buying partner. You should ask to you ERP manager to do it via the creation of a company." msgstr "Vous ne pouvez pas créer un client pour les commandes groupées. Vous devez demander au responsable de l'ERP de le faire, via la création d'une société." @@ -1597,13 +1567,13 @@ msgid "You can not create this item. Please ask to the logistic Manager." msgstr "Vous ne pouvez pas créer cet élément. Veuillez demander au responsable logistique." #. module: joint_buying_base -#: code:addons/joint_buying_base/models/res_partner.py:265 +#: code:addons/joint_buying_base/models/res_partner.py:255 #, python-format msgid "You can not delete this partner because it is related to a company for joint Buyings. Please archive it." msgstr "Vous ne pouvez pas supprimer ce contact, car il est lié à une société pour les commandes groupées. Vous pouvez simplement l'archiver." #. module: joint_buying_base -#: code:addons/joint_buying_base/models/res_partner.py:140 +#: code:addons/joint_buying_base/models/res_partner.py:130 #, python-format msgid "You can not link the supplier %s to the Joint Buying partner %s because you have other suppliers that are still related to him : \n" "\n" @@ -1631,7 +1601,7 @@ msgid "You can not update this item because you are not responsible for it" msgstr "Vous ne pouvez pas mettre à jour cet élément, car vous n'en êtes pas responsable." #. module: joint_buying_base -#: code:addons/joint_buying_base/models/res_partner.py:254 +#: code:addons/joint_buying_base/models/res_partner.py:244 #, python-format msgid "You can not update this partner this way you should ask to your ERP Manager to update this field via the related company." msgstr "Vous ne pouvez pas mettre à jour ce contact de cette manière, vous devez demander au responsable de votre ERP de mettre à jour les données, via la société associée." From c281981aced92bf1c514aa0270867f01292918d4 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 5 Apr 2024 11:44:28 +0200 Subject: [PATCH 04/12] [IMP] add new 'Loaded Weight' and 'Loaded Amount Untaxed' on joint.buying.tour model. Add graph and pivot view to display the new values --- joint_buying_base/i18n/fr.po | 40 ++++++++++++++----- joint_buying_base/models/joint_buying_tour.py | 28 +++++++++++++ .../reports/report_joint_buying_tour.xml | 29 +++++++++----- .../views/view_joint_buying_tour.xml | 32 ++++++++++++++- 4 files changed, 108 insertions(+), 21 deletions(-) diff --git a/joint_buying_base/i18n/fr.po b/joint_buying_base/i18n/fr.po index d2369814..cf213dea 100644 --- a/joint_buying_base/i18n/fr.po +++ b/joint_buying_base/i18n/fr.po @@ -6,8 +6,8 @@ msgid "" msgstr "" "Project-Id-Version: Odoo Server 12.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-04-05 08:43+0000\n" -"PO-Revision-Date: 2024-04-05 08:43+0000\n" +"POT-Creation-Date: 2024-04-05 10:18+0000\n" +"PO-Revision-Date: 2024-04-05 10:18+0000\n" "Last-Translator: <>\n" "Language-Team: \n" "MIME-Version: 1.0\n" @@ -16,7 +16,7 @@ msgstr "" "Plural-Forms: \n" #. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:260 +#: code:addons/joint_buying_base/models/joint_buying_tour.py:288 #, python-format msgid "%s (copy)" msgstr "%s (copie)" @@ -32,19 +32,19 @@ msgid "Company Address:" msgstr "Adresse de la société:" #. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:191 +#: code:addons/joint_buying_base/models/joint_buying_tour.py:205 #, python-format msgid "Delivery and pick-up" msgstr "Livraison et retrait" #. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:187 +#: code:addons/joint_buying_base/models/joint_buying_tour.py:201 #, python-format msgid "Truck loading" msgstr "Chargement du camion" #. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:189 +#: code:addons/joint_buying_base/models/joint_buying_tour.py:203 #, python-format msgid "Truck unloading" msgstr "Déchargement du camion" @@ -65,7 +65,7 @@ msgid " ( On " msgstr " ( Dans " #. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:184 +#: code:addons/joint_buying_base/models/joint_buying_tour.py:198 #, python-format msgid "Pause" msgstr "" @@ -102,7 +102,17 @@ msgstr "Durée" #. module: joint_buying_base #: model_terms:ir.ui.view,arch_db:joint_buying_base.report_joint_buying_tour_document -msgid "Payload (kg)" +msgid "Loaded Amount Untaxed" +msgstr "Montant HT chargé" + +#. module: joint_buying_base +#: model_terms:ir.ui.view,arch_db:joint_buying_base.report_joint_buying_tour_document +msgid "Loaded Weight" +msgstr "Poids chargé" + +#. module: joint_buying_base +#: model_terms:ir.ui.view,arch_db:joint_buying_base.report_joint_buying_tour_document +msgid "Payload" msgstr "Charge Utile (kg)" #. module: joint_buying_base @@ -516,7 +526,7 @@ msgid "Distance" msgstr "" #. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:125 +#: code:addons/joint_buying_base/models/joint_buying_tour.py:139 #, python-format msgid "Draft Tour" msgstr "Tournée en brouillon" @@ -852,7 +862,7 @@ msgid "Journey" msgstr "Trajet" #. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_tour.py:179 +#: code:addons/joint_buying_base/models/joint_buying_tour.py:193 #, python-format msgid "Journey from %s to %s" msgstr "Trajet de %s à %s" @@ -921,6 +931,16 @@ msgstr "Ligne" msgid "Load" msgstr "Charger" +#. module: joint_buying_base +#: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_tour__loaded_amount_untaxed +msgid "Loaded Amount Untaxed" +msgstr "Montant HT chargé" + +#. module: joint_buying_base +#: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_tour__loaded_weight +msgid "Loaded Weight" +msgstr "Poids chargé" + #. module: joint_buying_base #: model_terms:ir.ui.view,arch_db:joint_buying_base.report_joint_buying_tour_document_request_lines msgid "Loading" diff --git a/joint_buying_base/models/joint_buying_tour.py b/joint_buying_base/models/joint_buying_tour.py index 0a3884a1..51a6f6d7 100644 --- a/joint_buying_base/models/joint_buying_tour.py +++ b/joint_buying_base/models/joint_buying_tour.py @@ -7,6 +7,8 @@ from odoo import _, api, fields, models +from odoo.addons import decimal_precision as dp + from .res_partner import _JOINT_BUYING_PARTNER_CONTEXT @@ -100,6 +102,18 @@ class JointBuyingTour(models.Model): " passes through the current company.", ) + loaded_weight = fields.Float( + compute="_compute_loaded_data", + digits=dp.get_precision("Stock Weight"), + store=True, + ) + + loaded_amount_untaxed = fields.Float( + compute="_compute_loaded_data", + digits=dp.get_precision("Product Price"), + store=True, + ) + @api.onchange("type_id") def _onchange_type_id(self): if self.type_id and self.type_id.carrier_id: @@ -228,6 +242,20 @@ def _compute_points(self): tour.starting_point_id = journey_lines[0].starting_point_id tour.arrival_point_id = journey_lines[-1].arrival_point_id + @api.depends( + "line_ids.transport_request_line_ids.request_id.total_weight", + "line_ids.transport_request_line_ids.request_id.amount_untaxed", + ) + def _compute_loaded_data(self): + for tour in self: + requests = tour.mapped("line_ids.transport_request_line_ids.request_id") + data = requests.search_read( + domain=[("id", "in", requests.ids)], + fields=["total_weight", "amount_untaxed"], + ) + tour.loaded_weight = sum([x["total_weight"] for x in data]) + tour.loaded_amount_untaxed = sum([x["amount_untaxed"] for x in data]) + @api.depends("line_ids.starting_point_id", "line_ids.arrival_point_id") def _compute_is_on_my_way(self): current_partner = self.env.user.company_id.joint_buying_partner_id diff --git a/joint_buying_base/reports/report_joint_buying_tour.xml b/joint_buying_base/reports/report_joint_buying_tour.xml index 27e1d6dd..8d57ff18 100644 --- a/joint_buying_base/reports/report_joint_buying_tour.xml +++ b/joint_buying_base/reports/report_joint_buying_tour.xml @@ -82,26 +82,37 @@ -
-
+
+
Starting Point

-
+
Start Date

-
+
+ Payload +

kg

+
+
+ +
+
Duration

-
+
Distance -

+

km

+
+
+ Loaded Weight +

kg

-
- Payload (kg) -

+

+ Loaded Amount Untaxed +

diff --git a/joint_buying_base/views/view_joint_buying_tour.xml b/joint_buying_base/views/view_joint_buying_tour.xml index edba6fb2..0ea3f13f 100644 --- a/joint_buying_base/views/view_joint_buying_tour.xml +++ b/joint_buying_base/views/view_joint_buying_tour.xml @@ -52,6 +52,8 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + @@ -101,6 +103,8 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + @@ -161,12 +165,36 @@ There may be traffic jams, delays, unforeseen events, etc... + + joint.buying.tour + + + + + + + + + + + + joint.buying.tour + + + + + + + + + + My Tours ir.actions.act_window joint.buying.tour form - calendar,tree,form + calendar,tree,pivot,graph,form [('is_on_my_way', '=', True)] @@ -182,7 +210,7 @@ There may be traffic jams, delays, unforeseen events, etc... ir.actions.act_window joint.buying.tour form - calendar,tree,form + calendar,tree,pivot,graph,form From 2ba8fad884e4307382050162c0a960c564c413d6 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 5 Apr 2024 16:22:23 +0200 Subject: [PATCH 05/12] [IMP] joint_buying_* : Add supplier_id on joint.buying.transport.request model. - Make request_type field stored --- joint_buying_base/__manifest__.py | 2 +- .../migrations/12.0.7.0.0/end-migration.py | 15 ++++++++ .../models/joint_buying_transport_request.py | 35 ++++++++++++++----- .../view_joint_buying_transport_request.xml | 11 ++++++ .../models/joint_buying_transport_request.py | 29 ++++++++++----- .../models/joint_buying_transport_request.py | 29 +++++++++++---- 6 files changed, 97 insertions(+), 24 deletions(-) create mode 100644 joint_buying_base/migrations/12.0.7.0.0/end-migration.py diff --git a/joint_buying_base/__manifest__.py b/joint_buying_base/__manifest__.py index bb4879e6..ffe03781 100644 --- a/joint_buying_base/__manifest__.py +++ b/joint_buying_base/__manifest__.py @@ -3,7 +3,7 @@ # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). { "name": "Joint Buying - Base", - "version": "12.0.6.2.0", + "version": "12.0.7.0.0", "category": "GRAP - Logistics", "author": "GRAP,La Jardinière,Hashbang", "website": "https://github.com/grap/odoo-addons-logistics", diff --git a/joint_buying_base/migrations/12.0.7.0.0/end-migration.py b/joint_buying_base/migrations/12.0.7.0.0/end-migration.py new file mode 100644 index 00000000..3561c0ba --- /dev/null +++ b/joint_buying_base/migrations/12.0.7.0.0/end-migration.py @@ -0,0 +1,15 @@ +import logging + +from openupgradelib import openupgrade + +_logger = logging.getLogger(__name__) + + +@openupgrade.migrate() +def migrate(env, version): + TransportRequest = env["joint.buying.transport.request"] + requests = TransportRequest.search([]) + _logger.info(f"Recompute Supplier field for {len(requests)} transport requests ...") + requests._compute_supplier_id() + _logger.info(f"Recompute Request Type for {len(requests)} transport requests ...") + requests._compute_request_type() diff --git a/joint_buying_base/models/joint_buying_transport_request.py b/joint_buying_base/models/joint_buying_transport_request.py index 43e4e373..8354f3d0 100644 --- a/joint_buying_base/models/joint_buying_transport_request.py +++ b/joint_buying_base/models/joint_buying_transport_request.py @@ -33,8 +33,8 @@ class JointBuyingTransportRequest(models.Model): request_type = fields.Selection( selection=[("manual", "Manual")], - required=True, compute="_compute_request_type", + store=True, ) origin = fields.Char(compute="_compute_origin", store=True) @@ -51,10 +51,21 @@ class JointBuyingTransportRequest(models.Model): track_visibility=True, ) - manual_availability_date = fields.Datetime( - string="Availability Date (Manual)", + manual_supplier_id = fields.Many2one( + comodel_name="res.partner", + context=_JOINT_BUYING_PARTNER_CONTEXT, + ) + + supplier_id = fields.Many2one( + comodel_name="res.partner", + context=_JOINT_BUYING_PARTNER_CONTEXT, + compute="_compute_supplier_id", + store=True, + track_visibility=True, ) + manual_availability_date = fields.Datetime(string="Availability Date (Manual)") + availability_date = fields.Datetime( string="Availability Date", compute="_compute_availability_date", @@ -151,12 +162,18 @@ def write(self, vals): vals.update(self._INVALIDATE_VALS) return super().write(vals) - def _get_depends_origin(self): + def _get_depends_request_type(self): return ["state"] # fake, to make dependency working - def _get_depends_request_type(self): + def _get_depends_can_change(self): + return ["state"] # fake, to make dependency working + + def _get_depends_origin(self): return ["state"] # fake, to make dependency working + def _get_depends_supplier_id(self): + return ["manual_supplier_id"] + def _get_depends_availability_date(self): return ["manual_availability_date"] @@ -175,9 +192,6 @@ def _get_depends_total_weight(self): def _get_depends_description(self): return ["manual_description"] - def _get_depends_can_change(self): - return ["state"] # fake, to make dependency working - @api.depends("start_partner_id", "arrival_partner_id", "availability_date") def _compute_name(self): for request in self: @@ -202,6 +216,11 @@ def _compute_request_type(self): for request in self: request.request_type = "manual" + @api.depends(lambda x: x._get_depends_supplier_id()) + def _compute_supplier_id(self): + for request in self: + request.supplier_id = request.manual_supplier_id + @api.depends(lambda x: x._get_depends_availability_date()) def _compute_availability_date(self): for request in self: diff --git a/joint_buying_base/views/view_joint_buying_transport_request.xml b/joint_buying_base/views/view_joint_buying_transport_request.xml index 64474b5f..2e3e5b19 100644 --- a/joint_buying_base/views/view_joint_buying_transport_request.xml +++ b/joint_buying_base/views/view_joint_buying_transport_request.xml @@ -33,10 +33,12 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + @@ -50,6 +52,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). decoration-danger="state == 'not_computable' and (amount_untaxed != 0 or total_weight != 0)" > + @@ -85,6 +88,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). groups="base.group_erp_manager" /> + @@ -129,6 +133,13 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + diff --git a/joint_buying_product/models/joint_buying_transport_request.py b/joint_buying_product/models/joint_buying_transport_request.py index 093ffcb0..03866df3 100644 --- a/joint_buying_product/models/joint_buying_transport_request.py +++ b/joint_buying_product/models/joint_buying_transport_request.py @@ -19,13 +19,23 @@ class JointBuyingTransportRequest(models.Model): readonly=True, ) + def _get_depends_request_type(self): + res = super()._get_depends_request_type() + res.append("order_id") + return res + + def _get_depends_can_change(self): + res = super()._get_depends_can_change() + res += ["order_id"] + return res + def _get_depends_origin(self): res = super()._get_depends_origin() res.append("order_id") return res - def _get_depends_request_type(self): - res = super()._get_depends_request_type() + def _get_depends_supplier_id(self): + res = super()._get_depends_supplier_id() res.append("order_id") return res @@ -63,15 +73,10 @@ def _get_depends_description(self): ] return res - def _get_depends_can_change(self): - res = super()._get_depends_can_change() - res += ["order_id"] - return res - def _compute_origin(self): super( JointBuyingTransportRequest, self.filtered(lambda x: not x.order_id) - )._compute_request_type() + )._compute_origin() for request in self.filtered(lambda x: x.order_id): request.origin = request.order_id.name @@ -84,6 +89,14 @@ def _compute_request_type(self): for request in self.filtered(lambda x: x.order_id): request.request_type = "joint_buying" + def _compute_supplier_id(self): + super( + JointBuyingTransportRequest, self.filtered(lambda x: not x.order_id) + )._compute_supplier_id() + + for request in self.filtered(lambda x: x.order_id): + request.supplier_id = request.order_id.supplier_id + def _compute_availability_date(self): super( JointBuyingTransportRequest, self.filtered(lambda x: not x.order_id) diff --git a/joint_buying_sale/models/joint_buying_transport_request.py b/joint_buying_sale/models/joint_buying_transport_request.py index 821d0f3a..ba7d9922 100644 --- a/joint_buying_sale/models/joint_buying_transport_request.py +++ b/joint_buying_sale/models/joint_buying_transport_request.py @@ -18,13 +18,23 @@ class JointBuyingTransportRequest(models.Model): readonly=True, ) + def _get_depends_request_type(self): + res = super()._get_depends_request_type() + res.append("sale_order_id") + return res + + def _get_depends_can_change(self): + res = super()._get_depends_can_change() + res += ["sale_order_id"] + return res + def _get_depends_origin(self): res = super()._get_depends_origin() res.append("sale_order_id") return res - def _get_depends_request_type(self): - res = super()._get_depends_request_type() + def _get_depends_supplier_id(self): + res = super()._get_depends_supplier_id() res.append("sale_order_id") return res @@ -47,11 +57,6 @@ def _get_depends_description(self): ] return res - def _get_depends_can_change(self): - res = super()._get_depends_can_change() - res += ["sale_order_id"] - return res - def _compute_origin(self): super( JointBuyingTransportRequest, self.filtered(lambda x: not x.sale_order_id) @@ -68,6 +73,16 @@ def _compute_request_type(self): for request in self.filtered(lambda x: x.sale_order_id): request.request_type = "sale" + def _compute_supplier_id(self): + super( + JointBuyingTransportRequest, self.filtered(lambda x: not x.sale_order_id) + )._compute_supplier_id() + + for request in self.filtered(lambda x: x.sale_order_id): + request.supplier_id = ( + request.sale_order_id.sudo().company_id.joint_buying_partner_id + ) + def _compute_amount_untaxed(self): super( JointBuyingTransportRequest, self.filtered(lambda x: not x.sale_order_id) From 88bfa716371034ec47fd387cde669d02f37a0be1 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 18 Oct 2024 14:39:51 +0200 Subject: [PATCH 06/12] [FIX] joint_buying_base: Transport request view default filter includes now manual Transport Requests --- joint_buying_base/i18n/fr.po | 4 ++-- .../views/view_joint_buying_transport_request.xml | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/joint_buying_base/i18n/fr.po b/joint_buying_base/i18n/fr.po index cf213dea..c97eca59 100644 --- a/joint_buying_base/i18n/fr.po +++ b/joint_buying_base/i18n/fr.po @@ -1137,8 +1137,8 @@ msgstr "Planifiée" #. module: joint_buying_base #: model_terms:ir.ui.view,arch_db:joint_buying_base.view_joint_buying_transport_request_search -msgid "Positive Amount" -msgstr "Montant positif" +msgid "Positive Amount or Manual" +msgstr "Montant positif ou Demande manuelle" #. module: joint_buying_base #: model:res.partner.category,name:joint_buying_base.partner_category_poultry diff --git a/joint_buying_base/views/view_joint_buying_transport_request.xml b/joint_buying_base/views/view_joint_buying_transport_request.xml index 2e3e5b19..294491c7 100644 --- a/joint_buying_base/views/view_joint_buying_transport_request.xml +++ b/joint_buying_base/views/view_joint_buying_transport_request.xml @@ -34,9 +34,10 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). - @@ -207,7 +208,7 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). joint.buying.transport.request form tree,form - {'search_default_filter_amount_positive':1} + {'search_default_filter_amount_positive_or_manual':1} Date: Fri, 18 Oct 2024 15:39:52 +0200 Subject: [PATCH 07/12] [FIX] joint_buying_base : display transport request by date --- joint_buying_base/models/joint_buying_transport_request.py | 1 + 1 file changed, 1 insertion(+) diff --git a/joint_buying_base/models/joint_buying_transport_request.py b/joint_buying_base/models/joint_buying_transport_request.py index 8354f3d0..1d97956b 100644 --- a/joint_buying_base/models/joint_buying_transport_request.py +++ b/joint_buying_base/models/joint_buying_transport_request.py @@ -15,6 +15,7 @@ class JointBuyingTransportRequest(models.Model): _name = "joint.buying.transport.request" _inherit = ["mail.thread", "mail.activity.mixin"] _description = "Joint Buying Transport Request" + _order = "availability_date desc, supplier_id" _INVALIDATE_VALS = { "start_date": False, From ab56f20d6bc48b6039a4a8bea96535a8183a2766 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 18 Oct 2024 16:01:12 +0200 Subject: [PATCH 08/12] [IMP] joint_buying_base: add graph / pivot / calendar views on transport request model --- .../view_joint_buying_transport_request.xml | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/joint_buying_base/views/view_joint_buying_transport_request.xml b/joint_buying_base/views/view_joint_buying_transport_request.xml index 294491c7..4e2b29bb 100644 --- a/joint_buying_base/views/view_joint_buying_transport_request.xml +++ b/joint_buying_base/views/view_joint_buying_transport_request.xml @@ -44,6 +44,17 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + joint.buying.transport.request + + + + + + + + + joint.buying.transport.request @@ -202,12 +213,36 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + joint.buying.transport.request + + + + + + + + + + + + joint.buying.transport.request + + + + + + + + + + Transport Requests ir.actions.act_window joint.buying.transport.request form - tree,form + tree,calendar,pivot,graph,form {'search_default_filter_amount_positive_or_manual':1} From 7cb735bb8da53dd5a4d49a79a84f97374321068c Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 18 Oct 2024 16:15:51 +0200 Subject: [PATCH 09/12] [FIX] joint_buying_base: allow to search by global partners on transport request and tour views --- joint_buying_base/views/view_joint_buying_tour.xml | 6 ++++++ .../views/view_joint_buying_transport_request.xml | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/joint_buying_base/views/view_joint_buying_tour.xml b/joint_buying_base/views/view_joint_buying_tour.xml index 0ea3f13f..1ff5d0a8 100644 --- a/joint_buying_base/views/view_joint_buying_tour.xml +++ b/joint_buying_base/views/view_joint_buying_tour.xml @@ -196,6 +196,9 @@ There may be traffic jams, delays, unforeseen events, etc... form calendar,tree,pivot,graph,form [('is_on_my_way', '=', True)] + { + "joint_buying": 1, + } joint.buying.tour form calendar,tree,pivot,graph,form + { + "joint_buying": 1, + } diff --git a/joint_buying_base/views/view_joint_buying_transport_request.xml b/joint_buying_base/views/view_joint_buying_transport_request.xml index 4e2b29bb..e7a09cfe 100644 --- a/joint_buying_base/views/view_joint_buying_transport_request.xml +++ b/joint_buying_base/views/view_joint_buying_transport_request.xml @@ -243,7 +243,10 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). joint.buying.transport.request form tree,calendar,pivot,graph,form - {'search_default_filter_amount_positive_or_manual':1} + { + "search_default_filter_amount_positive_or_manual": 1, + "joint_buying": 1, + } Date: Fri, 18 Oct 2024 16:18:41 +0200 Subject: [PATCH 10/12] [IMP] joint_buying_base: allow to quick search by starting / arrival points on tour views --- joint_buying_base/views/view_joint_buying_tour.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/joint_buying_base/views/view_joint_buying_tour.xml b/joint_buying_base/views/view_joint_buying_tour.xml index 1ff5d0a8..8adee15a 100644 --- a/joint_buying_base/views/view_joint_buying_tour.xml +++ b/joint_buying_base/views/view_joint_buying_tour.xml @@ -24,6 +24,8 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + + From 0b4737d2185906debaed1ebca1283a5bf42aa692 Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Fri, 18 Oct 2024 16:39:42 +0200 Subject: [PATCH 11/12] [FIX] joint_buying_base: Recompute all the start_date of the model joint_buying_transport_request, as the previous value was bad computed --- .../migrations/12.0.7.0.0/pre-migration.py | 38 +++++++++++++++++++ .../models/joint_buying_transport_request.py | 2 +- 2 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 joint_buying_base/migrations/12.0.7.0.0/pre-migration.py diff --git a/joint_buying_base/migrations/12.0.7.0.0/pre-migration.py b/joint_buying_base/migrations/12.0.7.0.0/pre-migration.py new file mode 100644 index 00000000..a517f3b8 --- /dev/null +++ b/joint_buying_base/migrations/12.0.7.0.0/pre-migration.py @@ -0,0 +1,38 @@ +# Copyright (C) 2024-Today: GRAP (http://www.grap.coop) +# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). + +import logging + +from openupgradelib import openupgrade + +_logger = logging.getLogger(__name__) + + +@openupgrade.migrate() +def migrate(env, version): + + _logger.info( + "Fix bad computation of joint_buying_transport_request.start_date field." + ) + openupgrade.logged_query( + env.cr, + """ + UPDATE joint_buying_transport_request tr_main + SET start_date = tmp.min_start_date + FROM ( + SELECT tr.id as transport_request_id, + min(tl.start_date) as min_start_date + FROM joint_buying_transport_request tr + INNER JOIN joint_buying_transport_request_line trl + ON trl.request_id = tr.id + INNER JOIN joint_buying_tour_line tl + ON tl.id = trl.tour_line_id + WHERE tr.state = 'computed' + GROUP BY tr.id + ) as tmp + WHERE + tr_main.id = tmp.transport_request_id + AND tr_main.start_date != tmp.min_start_date; + """, + ) diff --git a/joint_buying_base/models/joint_buying_transport_request.py b/joint_buying_base/models/joint_buying_transport_request.py index 1d97956b..1b12df0d 100644 --- a/joint_buying_base/models/joint_buying_transport_request.py +++ b/joint_buying_base/models/joint_buying_transport_request.py @@ -291,7 +291,7 @@ def _set_tour_lines(self, tour_lines): self.write( { - "start_date": max(tour_lines.mapped("start_date")), + "start_date": min(tour_lines.mapped("start_date")), "arrival_date": max(tour_lines.mapped("arrival_date")), "state": "computed", "line_ids": [(5,)] + [(0, 0, x) for x in line_vals], From fcd4bf39d3e03daae40f9aa1e75c08178a6ff8db Mon Sep 17 00:00:00 2001 From: Sylvain LE GAL Date: Sat, 19 Oct 2024 01:35:47 +0200 Subject: [PATCH 12/12] [REF] update translation --- joint_buying_account/i18n/fr.po | 10 +++++----- joint_buying_base/i18n/fr.po | 14 +++++++++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/joint_buying_account/i18n/fr.po b/joint_buying_account/i18n/fr.po index 0af35237..68020581 100644 --- a/joint_buying_account/i18n/fr.po +++ b/joint_buying_account/i18n/fr.po @@ -16,7 +16,7 @@ msgstr "" "Plural-Forms: \n" #. module: joint_buying_account -#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:179 +#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:195 #, python-format msgid "\n" "- Non-commissioned sale: %s ; %.2f €" @@ -50,7 +50,7 @@ msgid "Commission VAT 20% Excl" msgstr "Commission 20% HT" #. module: joint_buying_account -#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:165 +#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:181 #, python-format msgid "Commission on %s deposited on %s\n" "- Ordered Amount : %.2f €\n" @@ -118,13 +118,13 @@ msgid "ID" msgstr "" #. module: joint_buying_account -#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:124 +#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:139 #, python-format msgid "Incorrect fiscal settings block the possibility to generate commission invoices : Incorrect tax type on the tax %s" msgstr "Le paramétrage fiscal incorrect empêche de générer des factures de commission : type de taxe incorrect sur la taxe %s" #. module: joint_buying_account -#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:114 +#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:129 #, python-format msgid "Incorrect fiscal settings block the possibility to generate commission invoices : Too many taxes %s" msgstr "Le paramétrage fiscal incorrect empêche de générer des factures de commissions : Trop de taxes %s" @@ -245,7 +245,7 @@ msgid "Wizard" msgstr "Assistant" #. module: joint_buying_account -#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:196 +#: code:addons/joint_buying_account/wizards/joint_buying_invoice_commission_wizard_line.py:212 #, python-format msgid "You should define a local partner for the supplier %s." msgstr "Vous devez définir un partenaire local pour le fournisseur %s." diff --git a/joint_buying_base/i18n/fr.po b/joint_buying_base/i18n/fr.po index c97eca59..6fc84164 100644 --- a/joint_buying_base/i18n/fr.po +++ b/joint_buying_base/i18n/fr.po @@ -965,7 +965,7 @@ msgid "Manager" msgstr "Gestionnaire" #. module: joint_buying_base -#: code:addons/joint_buying_base/models/joint_buying_transport_request.py:198 +#: code:addons/joint_buying_base/models/joint_buying_transport_request.py:213 #: selection:joint.buying.transport.request,request_type:0 #, python-format msgid "Manual" @@ -976,6 +976,11 @@ msgstr "Manuel" msgid "Manual Description" msgstr "Description (Manuelle)" +#. module: joint_buying_base +#: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_transport_request__manual_supplier_id +msgid "Manual Supplier" +msgstr "Fournisseur manuel" + #. module: joint_buying_base #: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_carrier__message_has_error #: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_tour__message_has_error @@ -1152,6 +1157,7 @@ msgstr "Demande" #. module: joint_buying_base #: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_transport_request__request_type +#: model_terms:ir.ui.view,arch_db:joint_buying_base.view_joint_buying_transport_request_search msgid "Request Type" msgstr "Type de demande" @@ -1176,6 +1182,11 @@ msgstr "Les prévisions de trajets sont données à titre indicatif seulement ! msgid "Salary Cost" msgstr "Coût des salaires" +#. module: joint_buying_base +#: selection:joint.buying.transport.request,request_type:0 +msgid "Sale Order" +msgstr "Bon de commande" + #. module: joint_buying_base #: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_tour_line__sequence #: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_wizard_set_tour_line__sequence @@ -1302,6 +1313,7 @@ msgid "Summary" msgstr "Résumé" #. module: joint_buying_base +#: model:ir.model.fields,field_description:joint_buying_base.field_joint_buying_transport_request__supplier_id #: model_terms:ir.ui.view,arch_db:joint_buying_base.view_res_partner_form msgid "Supplier" msgstr "Fournisseur"