From 367cb1af93cbe92cac37522ce40a4d5b713aa547 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Thu, 27 Oct 2022 21:57:19 +0200 Subject: [PATCH] [MIG] purchase_usability to v16 --- purchase_usability/__manifest__.py | 6 +- purchase_usability/models/product_template.py | 2 +- purchase_usability/models/purchase_order.py | 71 ++++++++++--------- purchase_usability/models/res_partner.py | 2 +- purchase_usability/views/purchase_order.xml | 38 +--------- purchase_usability/views/purchase_report.xml | 34 +-------- 6 files changed, 45 insertions(+), 108 deletions(-) diff --git a/purchase_usability/__manifest__.py b/purchase_usability/__manifest__.py index dd65bc6..7e2d580 100644 --- a/purchase_usability/__manifest__.py +++ b/purchase_usability/__manifest__.py @@ -1,10 +1,10 @@ -# Copyright (C) 2014-2020 Akretion (http://www.akretion.com) +# Copyright 2014-2022 Akretion (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). { 'name': 'Purchase Usability', - 'version': '14.0.1.0.0', + 'version': '16.0.1.0.0', 'category': 'Purchases', 'license': 'AGPL-3', 'summary': 'Usability improvements on purchase module', @@ -16,5 +16,5 @@ 'views/purchase_report.xml', 'views/account_move.xml', ], - 'installable': False, + 'installable': True, } diff --git a/purchase_usability/models/product_template.py b/purchase_usability/models/product_template.py index 459c9ad..1d80428 100644 --- a/purchase_usability/models/product_template.py +++ b/purchase_usability/models/product_template.py @@ -1,4 +1,4 @@ -# Copyright 2016-2020 Akretion France +# Copyright 2016-2022 Akretion France # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/purchase_usability/models/purchase_order.py b/purchase_usability/models/purchase_order.py index df0c462..54ce2af 100644 --- a/purchase_usability/models/purchase_order.py +++ b/purchase_usability/models/purchase_order.py @@ -1,4 +1,4 @@ -# Copyright 2015-2020 Akretion France (http://www.akretion.com) +# Copyright 2015-2022 Akretion France (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -85,7 +85,7 @@ class PurchaseOrderLine(models.Model): partner_id = line.order_id.partner_id.commercial_partner_id.id if partner_id: for supplier_info in line.product_id.seller_ids: - if supplier_info.name.id == partner_id: + if supplier_info.partner_id.id == partner_id: code = supplier_info.product_code break line.product_supplier_code = code @@ -101,40 +101,41 @@ class PurchaseOrderLine(models.Model): product_lang = product_lang.with_context(display_default_code=False) return super()._get_product_purchase_description(product_lang) - @api.onchange('product_qty', 'product_uom') - def _onchange_quantity(self): +# TODO see how we could restore this feature +# @api.onchange('product_qty', 'product_uom') +# def _onchange_quantity(self): # When the user has manually set a price and/or planned_date # he is often upset when Odoo changes it when he changes the qty # So we add a warning... - res = {} - old_price = self.price_unit - old_date_planned = self.date_planned - super()._onchange_quantity() - new_price = self.price_unit - new_date_planned = self.date_planned - prec = self.env['decimal.precision'].precision_get('Product Price') - price_compare = float_compare(old_price, new_price, precision_digits=prec) - if price_compare or old_date_planned != new_date_planned: - res['warning'] = { - 'title': _('Updates'), - 'message': _( - "Due to the update of the ordered quantity on line '%s', " - "the following data has been updated using the supplier info " - "of the product:" - ) % self.name - } - if price_compare: - res['warning']['message'] += _( - "\nOld price: %s\nNew price: %s") % ( - format_amount( - self.env, old_price, self.order_id.currency_id), - format_amount( - self.env, new_price, self.order_id.currency_id)) +# res = {} +# old_price = self.price_unit +# old_date_planned = self.date_planned +# super()._onchange_quantity() +# new_price = self.price_unit +# new_date_planned = self.date_planned +# prec = self.env['decimal.precision'].precision_get('Product Price') +# price_compare = float_compare(old_price, new_price, precision_digits=prec) +# if price_compare or old_date_planned != new_date_planned: +# res['warning'] = { +# 'title': _('Updates'), +# 'message': _( +# "Due to the update of the ordered quantity on line '%s', " +# "the following data has been updated using the supplier info " +# "of the product:" +# ) % self.name +# } +# if price_compare: +# res['warning']['message'] += _( +# "\nOld price: %s\nNew price: %s") % ( +# format_amount( +# self.env, old_price, self.order_id.currency_id), +# format_amount( +# self.env, new_price, self.order_id.currency_id)) - if old_date_planned != new_date_planned: - res['warning']['message'] += _( - "\nOld delivery date: %s\nNew delivery date: %s") % ( - format_datetime(self.env, old_date_planned), - format_datetime(self.env, new_date_planned), - ) - return res +# if old_date_planned != new_date_planned: +# res['warning']['message'] += _( +# "\nOld delivery date: %s\nNew delivery date: %s") % ( +# format_datetime(self.env, old_date_planned), +# format_datetime(self.env, new_date_planned), +# ) +# return res diff --git a/purchase_usability/models/res_partner.py b/purchase_usability/models/res_partner.py index b3d6ef0..932ad1e 100644 --- a/purchase_usability/models/res_partner.py +++ b/purchase_usability/models/res_partner.py @@ -1,4 +1,4 @@ -# Copyright 2017-2020 Akretion France +# Copyright 2017-2022 Akretion France # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/purchase_usability/views/purchase_order.xml b/purchase_usability/views/purchase_order.xml index 55d8a9e..49733e6 100644 --- a/purchase_usability/views/purchase_order.xml +++ b/purchase_usability/views/purchase_order.xml @@ -22,18 +22,6 @@ - - - - - - - - analytic.group_analytic_tags - @@ -65,7 +53,7 @@ Reference, Origin or Vendor Reference - ['|', '|', ('name', 'ilike', self), ('origin', 'ilike', self), ('partner_ref', 'ilike', self)] + ['|', '|', '|', ('name', 'ilike', self), ('origin', 'ilike', self), ('partner_ref', 'ilike', self), ('partner_id', 'child_of', self)] @@ -104,7 +92,6 @@ - {'search_default_draft': 1, 'quotation_only': True} @@ -116,20 +103,15 @@ purchase.order.line - - + - - - - - + @@ -137,18 +119,4 @@ - - usability.purchase.order.line.search - purchase.order.line - - - - - - - - - - - diff --git a/purchase_usability/views/purchase_report.xml b/purchase_usability/views/purchase_report.xml index 9e95524..1bd9c63 100644 --- a/purchase_usability/views/purchase_report.xml +++ b/purchase_usability/views/purchase_report.xml @@ -1,6 +1,6 @@ @@ -11,36 +11,4 @@ pivot,graph,tree - - purchase.report - - - - - - - - - - purchase.report.tree - purchase.report - - - - - - - - - - - - - - - - - - -