diff --git a/purchase_usability/__init__.py b/purchase_usability/__init__.py index 6e1648e..0650744 100644 --- a/purchase_usability/__init__.py +++ b/purchase_usability/__init__.py @@ -1,3 +1 @@ -from . import purchase -from . import product -from . import partner +from . import models diff --git a/purchase_usability/__manifest__.py b/purchase_usability/__manifest__.py index 9058ccb..e81aec9 100644 --- a/purchase_usability/__manifest__.py +++ b/purchase_usability/__manifest__.py @@ -1,10 +1,10 @@ -# Copyright (C) 2014-2019 Akretion (http://www.akretion.com) +# Copyright (C) 2014-2020 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': '12.0.1.0.0', + 'version': '14.0.1.0.0', 'category': 'Purchases', 'license': 'AGPL-3', 'summary': 'Usability improvements on purchase module', @@ -12,7 +12,8 @@ 'website': 'http://www.akretion.com', 'depends': ['purchase'], 'data': [ - 'purchase_view.xml', + 'views/purchase_order.xml', + 'views/purchase_report.xml', ], - 'installable': False, + 'installable': True, } diff --git a/purchase_usability/models/__init__.py b/purchase_usability/models/__init__.py new file mode 100644 index 0000000..c5a3b0e --- /dev/null +++ b/purchase_usability/models/__init__.py @@ -0,0 +1,3 @@ +from . import purchase_order +from . import product_template +from . import res_partner diff --git a/purchase_usability/models/product_template.py b/purchase_usability/models/product_template.py new file mode 100644 index 0000000..459c9ad --- /dev/null +++ b/purchase_usability/models/product_template.py @@ -0,0 +1,12 @@ +# Copyright 2016-2020 Akretion France +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +from odoo import fields, models + + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + purchase_method = fields.Selection(tracking=True) + purchase_line_warn = fields.Selection(tracking=True) diff --git a/purchase_usability/purchase.py b/purchase_usability/models/purchase_order.py similarity index 59% rename from purchase_usability/purchase.py rename to purchase_usability/models/purchase_order.py index ac42171..a3c0817 100644 --- a/purchase_usability/purchase.py +++ b/purchase_usability/models/purchase_order.py @@ -1,26 +1,23 @@ -# -*- coding: utf-8 -*- -# Copyright 2015-2019 Akretion France (http://www.akretion.com) +# Copyright 2015-2020 Akretion France (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields, api +from odoo import api, fields, models from odoo.tools.misc import formatLang class PurchaseOrder(models.Model): _inherit = 'purchase.order' - dest_address_id = fields.Many2one(track_visibility='onchange') - currency_id = fields.Many2one(track_visibility='onchange') - payment_term_id = fields.Many2one(track_visibility='onchange') - fiscal_position_id = fields.Many2one(track_visibility='onchange') - partner_ref = fields.Char(track_visibility='onchange') - # field 'partner_id': native value for track_visibility='always' - partner_id = fields.Many2one(track_visibility='onchange') + dest_address_id = fields.Many2one(tracking=True) + currency_id = fields.Many2one(tracking=True) + payment_term_id = fields.Many2one(tracking=True) + fiscal_position_id = fields.Many2one(tracking=True) + partner_ref = fields.Char(tracking=True) # the field 'delivery_partner_id' is used in report # the compute method of that field is inherited in purchase_stock_usability delivery_partner_id = fields.Many2one( - 'res.partner', compute='_compute_delivery_partner_id', readonly=True) + 'res.partner', compute='_compute_delivery_partner_id') @api.depends('dest_address_id') def _compute_delivery_partner_id(self): @@ -33,7 +30,6 @@ class PurchaseOrder(models.Model): return action # Re-write native name_get() to use amount_untaxed instead of amount_total - @api.multi @api.depends('name', 'partner_ref') def name_get(self): result = [] @@ -41,7 +37,8 @@ class PurchaseOrder(models.Model): name = po.name if po.partner_ref: name += ' (' + po.partner_ref + ')' - if self.env.context.get('show_total_amount') and po.amount_total: - name += ': ' + formatLang(self.env, po.amount_untaxed, currency_obj=po.currency_id) + if self.env.context.get('show_total_amount') and po.amount_untaxed: + name += ': ' + formatLang( + self.env, po.amount_untaxed, currency_obj=po.currency_id) result.append((po.id, name)) return result diff --git a/purchase_usability/partner.py b/purchase_usability/models/res_partner.py similarity index 58% rename from purchase_usability/partner.py rename to purchase_usability/models/res_partner.py index 7d13e5f..b3d6ef0 100644 --- a/purchase_usability/partner.py +++ b/purchase_usability/models/res_partner.py @@ -1,11 +1,11 @@ -# Copyright 2017-2019 Akretion France +# Copyright 2017-2020 Akretion France # @author: Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import models, fields +from odoo import fields, models class ResPartner(models.Model): _inherit = 'res.partner' - purchase_warn = fields.Selection(track_visibility='onchange') + purchase_warn = fields.Selection(tracking=True) diff --git a/purchase_usability/product.py b/purchase_usability/product.py deleted file mode 100644 index 5e8c72b..0000000 --- a/purchase_usability/product.py +++ /dev/null @@ -1,12 +0,0 @@ -# Copyright 2016-2019 Akretion France -# @author: Alexis de Lattre -# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). - -from odoo import models, fields - - -class ProductTemplate(models.Model): - _inherit = 'product.template' - - purchase_method = fields.Selection(track_visibility='onchange') - purchase_line_warn = fields.Selection(track_visibility='onchange') diff --git a/purchase_usability/stock_view.xml b/purchase_usability/stock_view.xml deleted file mode 100644 index a6d6c20..0000000 --- a/purchase_usability/stock_view.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - purchase_usability.stock.picking.form - stock.picking - - - - - - - - - - - diff --git a/purchase_usability/purchase_view.xml b/purchase_usability/views/purchase_order.xml similarity index 65% rename from purchase_usability/purchase_view.xml rename to purchase_usability/views/purchase_order.xml index e6947ce..87ff95a 100644 --- a/purchase_usability/purchase_view.xml +++ b/purchase_usability/views/purchase_order.xml @@ -1,6 +1,6 @@ @@ -44,14 +44,9 @@ + because the info it carries can be interesting. So we just hide it by default --> - 1 - - - - + hide @@ -65,8 +60,8 @@ - Reference or Origin - ['|', ('name', 'ilike', self), ('origin', 'ilike', self)] + Reference, Origin or Vendor Reference + ['|', '|', ('name', 'ilike', self), ('origin', 'ilike', self), ('partner_ref', 'ilike', self)] @@ -108,7 +103,8 @@ - {'search_default_draft': 1} + {'search_default_draft': 1, 'quotation_only': True} + [('state', 'not in', ('purchase', 'done'))] @@ -130,7 +126,6 @@ - @@ -147,65 +142,9 @@ - + - - usability.purchase.order.line.pivot - purchase.order.line - - - - - - - - - - - Purchase Order Lines - purchase.order.line - tree,form,pivot - - - - - - pivot,graph,tree - - - - purchase.report - - - - - - - - - - - - purchase.report.tree - purchase.report - - - - - - - - - - - - - - - - - diff --git a/purchase_usability/views/purchase_report.xml b/purchase_usability/views/purchase_report.xml new file mode 100644 index 0000000..9e95524 --- /dev/null +++ b/purchase_usability/views/purchase_report.xml @@ -0,0 +1,46 @@ + + + + + + + pivot,graph,tree + + + + purchase.report + + + + + + + + + + purchase.report.tree + purchase.report + + + + + + + + + + + + + + + + + + + +