diff --git a/sale_usability/__manifest__.py b/sale_usability/__manifest__.py index 05a159f..08950e9 100644 --- a/sale_usability/__manifest__.py +++ b/sale_usability/__manifest__.py @@ -1,10 +1,10 @@ -# Copyright 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': 'Sale Usability', - 'version': '14.0.1.0.0', + 'version': '16.0.1.0.0', 'category': 'Sales', 'license': 'AGPL-3', 'summary': 'Usability improvements on sale module', @@ -12,8 +12,8 @@ 'website': 'http://www.akretion.com', 'depends': [ 'sale', - 'account_usability', # for company view - 'base_view_inheritance_extension', +# 'account_usability', # for company view +# 'base_view_inheritance_extension', ], 'data': [ 'views/sale_order.xml', @@ -21,10 +21,10 @@ 'views/sale_report.xml', 'views/product_pricelist_item.xml', 'views/account_move.xml', - 'views/res_company.xml', +# 'views/res_company.xml', TODO uncomment once account_usa is ported "views/res_partner.xml", 'wizards/sale_invoice_discount_all_lines_view.xml', 'security/ir.model.access.csv', ], - 'installable': False, + 'installable': True, } diff --git a/sale_usability/models/account_move.py b/sale_usability/models/account_move.py index 04fcfee..8481a7b 100644 --- a/sale_usability/models/account_move.py +++ b/sale_usability/models/account_move.py @@ -1,46 +1,14 @@ -# Copyright (C) 2015-2019 Akretion (http://www.akretion.com) +# Copyright 2015-2022 Akretion (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models +from odoo import models from collections import OrderedDict class AccountMove(models.Model): _inherit = 'account.move' - # sale_ids is kind of the symetric field of invoice_ids on sale.order - sale_ids = fields.Many2many( - 'sale.order', string='Sale Orders', compute="_compute_sale_ids") - sale_count = fields.Integer( - string='Sale Order Count', compute='_compute_sale_ids') - - @api.depends('invoice_line_ids.sale_line_ids') - def _compute_sale_ids(self): - for invoice in self: - if invoice.move_type == 'out_invoice': - sales = invoice.invoice_line_ids.mapped('sale_line_ids').\ - mapped('order_id') - invoice.sale_ids = sales.ids - invoice.sale_count = len(sales.ids) - else: - invoice.sale_ids = [] - invoice.sale_count = 0 - - def show_sale_orders(self): - self.ensure_one() - action = self.env.ref('sale.action_orders').sudo().read()[0] - sales = self.sale_ids - if len(sales) > 1: - action['domain'] = [('id', 'in', sales.ids)] - else: - action.update({ - 'res_id': sales.id, - 'view_mode': 'form,tree,kanban,calendar,pivot,graph,activity', - 'views': False, - }) - return action - def py3o_lines_layout_groupby_order(self, subtotal=True): # This method is an alternative to the method py3o_lines_layout() # defined above: you just have to change the call in the invoice diff --git a/sale_usability/models/product_template.py b/sale_usability/models/product_template.py index 6627df1..6584296 100644 --- a/sale_usability/models/product_template.py +++ b/sale_usability/models/product_template.py @@ -1,4 +1,4 @@ -# Copyright 2017-2019 Akretion France +# Copyright 2017-2022 Akretion France # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -12,3 +12,4 @@ class ProductTemplate(models.Model): expense_policy = fields.Selection(tracking=True) invoice_policy = fields.Selection(tracking=True) sale_line_warn = fields.Selection(tracking=True) + expense_policy = fields.Selection(tracking=True) diff --git a/sale_usability/models/res_company.py b/sale_usability/models/res_company.py index f8434cb..388df89 100644 --- a/sale_usability/models/res_company.py +++ b/sale_usability/models/res_company.py @@ -1,4 +1,4 @@ -# Copyright 2021 Akretion France (https://akretion.com/) +# Copyright 2021-2022 Akretion France (https://akretion.com/) # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/sale_usability/models/res_partner.py b/sale_usability/models/res_partner.py index efc7b7d..faf5a2b 100644 --- a/sale_usability/models/res_partner.py +++ b/sale_usability/models/res_partner.py @@ -1,4 +1,4 @@ -# Copyright 2017-2020 Akretion France (https://akretion.com/) +# Copyright 2017-2022 Akretion France (https://akretion.com/) # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). diff --git a/sale_usability/models/sale_order.py b/sale_usability/models/sale_order.py index c218d4f..9823f2b 100644 --- a/sale_usability/models/sale_order.py +++ b/sale_usability/models/sale_order.py @@ -2,9 +2,8 @@ # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import api, fields, models, _ -from odoo.tools import float_is_zero, float_compare -from odoo.tools.misc import formatLang +from odoo import api, fields, models +from odoo.tools import float_is_zero class SaleOrder(models.Model): @@ -16,7 +15,6 @@ class SaleOrder(models.Model): amount_tax = fields.Monetary(tracking=True) partner_shipping_id = fields.Many2one(tracking=True) partner_invoice_id = fields.Many2one(tracking=True) - pricelist_id = fields.Many2one(tracking=True) payment_term_id = fields.Many2one(tracking=True) fiscal_position_id = fields.Many2one(tracking=True) # for reports @@ -97,33 +95,33 @@ class SaleOrderLine(models.Model): product_barcode = fields.Char( related='product_id.barcode', string="Product Barcode") - @api.onchange('product_uom', 'product_uom_qty') - def product_uom_change(self): +# @api.onchange('product_uom', 'product_uom_qty') +# def product_uom_change(self): # When the user has manually set a custom price # he is often upset when Odoo changes it when he changes the qty # So we add a warning in which we recall the old price. - res = {} - old_price = self.price_unit - super().product_uom_change() - new_price = self.price_unit - prec = self.env['decimal.precision'].precision_get('Product Price') - if float_compare(old_price, new_price, precision_digits=prec): - pricelist = self.order_id.pricelist_id - res['warning'] = { - 'title': _('Price updated'), - 'message': _( - "Due to the update of the ordered quantity on line '%s', " - "the price has been updated according to pricelist '%s'.\n" - "Old price: %s\n" - "New price: %s") % ( - self.name, - pricelist.display_name, - formatLang( - self.env, old_price, currency_obj=pricelist.currency_id), - formatLang( - self.env, new_price, currency_obj=pricelist.currency_id)) - } - return res +# res = {} +# old_price = self.price_unit +# super().product_uom_change() +# new_price = self.price_unit +# prec = self.env['decimal.precision'].precision_get('Product Price') +# if float_compare(old_price, new_price, precision_digits=prec): +# pricelist = self.order_id.pricelist_id +# res['warning'] = { +# 'title': _('Price updated'), +# 'message': _( +# "Due to the update of the ordered quantity on line '%s', " +# "the price has been updated according to pricelist '%s'.\n" +# "Old price: %s\n" +# "New price: %s") % ( +# self.name, +# pricelist.display_name, +# formatLang( +# self.env, old_price, currency_obj=pricelist.currency_id), +# formatLang( +# self.env, new_price, currency_obj=pricelist.currency_id)) +# } +# return res def get_sale_order_line_multiline_description_sale(self, product): # This is useful when you want to have the product code in a dedicated diff --git a/sale_usability/readme/DESCRIPTION.rst b/sale_usability/readme/DESCRIPTION.rst index 50e6a4d..71a297c 100644 --- a/sale_usability/readme/DESCRIPTION.rst +++ b/sale_usability/readme/DESCRIPTION.rst @@ -1,14 +1,12 @@ This modules adds the following functions: * Display amount untaxed in tree view -* Add sale_ids and sale_count on Invoice * Methods for py3o sale reports * Add tracking on partner warning fields * Add tracking on product fields * Add tracking on Sale Order fields * Add menu for Pricelist Items * Add `has_discount` field on Sale Order -* Restore drill-through on sale and invoice reports * Move client_order_ref from the second tab to the top * Protect Cancel button with a confirmation pop-up * Remove Sale Orders from Quotations menu diff --git a/sale_usability/views/account_move.xml b/sale_usability/views/account_move.xml index ee49ed0..a7a6841 100644 --- a/sale_usability/views/account_move.xml +++ b/sale_usability/views/account_move.xml @@ -1,37 +1,18 @@ - - sale_usability.customer.invoice.form - account.move - - - -
- -
-
-
- sale_usability.account.move.form account.move - + diff --git a/sale_usability/views/product_category.xml b/sale_usability/views/product_category.xml index 3af86f0..f7ab259 100644 --- a/sale_usability/views/product_category.xml +++ b/sale_usability/views/product_category.xml @@ -1,6 +1,6 @@ @@ -11,6 +11,6 @@ similar to what we have in Stock > Configuration > Products because we need this menu entry even if the 'stock' module is not installed --> + parent="sale.prod_config_main" sequence="5"/>
diff --git a/sale_usability/views/product_pricelist_item.xml b/sale_usability/views/product_pricelist_item.xml index 1df3ab4..5cffcf5 100644 --- a/sale_usability/views/product_pricelist_item.xml +++ b/sale_usability/views/product_pricelist_item.xml @@ -1,6 +1,6 @@ diff --git a/sale_usability/views/res_company.xml b/sale_usability/views/res_company.xml index a2f9f73..c360fcc 100644 --- a/sale_usability/views/res_company.xml +++ b/sale_usability/views/res_company.xml @@ -1,6 +1,6 @@ diff --git a/sale_usability/views/res_partner.xml b/sale_usability/views/res_partner.xml index f097b43..4ea6bff 100644 --- a/sale_usability/views/res_partner.xml +++ b/sale_usability/views/res_partner.xml @@ -6,7 +6,7 @@ - + diff --git a/sale_usability/views/sale_order.xml b/sale_usability/views/sale_order.xml index 18522ef..3773f7f 100644 --- a/sale_usability/views/sale_order.xml +++ b/sale_usability/views/sale_order.xml @@ -1,6 +1,6 @@ @@ -15,16 +15,16 @@ selection + - - + + + 1 + + + + 1 + + + + 1 + @@ -62,6 +73,7 @@ 0 + hide @@ -94,10 +106,6 @@ https://github.com/odoo/odoo/commit/c1e5ab9b1331c3cb7dc2232bf78952bdb40ad939 --> [('state', 'in', ('draft', 'sent', 'cancel'))] - - [('state', 'in', ('draft', 'sent', 'cancel'))] - - usability.sale.order.line.search sale.order.line diff --git a/sale_usability/views/sale_report.xml b/sale_usability/views/sale_report.xml index 63175cb..3ace3d7 100644 --- a/sale_usability/views/sale_report.xml +++ b/sale_usability/views/sale_report.xml @@ -1,6 +1,6 @@ @@ -8,48 +8,17 @@ - + usability.sale.report.tree sale.report - - - - - - - - - - - - - - - - - - - {'search_default_Sales': 1} - - - - usability.sale.report.pivot - sale.report - - - - - - - - - - usability.sale.report.search - sale.report - + - + + + + +