diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..890ff01 --- /dev/null +++ b/.gitignore @@ -0,0 +1,56 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] + +# C extensions +*.so + +# Distribution / packaging +.Python +env/ +bin/ +build/ +develop-eggs/ +dist/ +eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +*.egg-info/ +.installed.cfg +*.egg + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.coverage +.cache +nosetests.xml +coverage.xml + +# Translations +*.mo + +# Pycharm +.idea + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# Rope +.ropeproject + +# Sphinx documentation +docs/_build/ + +# Backup files +*~ +*.swp diff --git a/base_usability/models/misc.py b/base_usability/models/misc.py index 53c1968..894daee 100644 --- a/base_usability/models/misc.py +++ b/base_usability/models/misc.py @@ -17,32 +17,3 @@ class BaseLanguageInstall(models.TransientModel): _inherit = 'base.language.install' overwrite = fields.Boolean(default=True) - - -class BaseUsabilityInstalled(models.AbstractModel): - _name = "base.usability.installed" - _description = "technical flag to see if base_usability module is installed" - - -formatLang_original = misc.formatLang - -def formatLang(self, value, digits=None, grouping=True, monetary=False, - dp=False, currency_obj=False, int_no_digits=True): - with api.Environment.manage(): - env = api.Environment(self.cr, self.uid, {}) - if ( - 'base.usability.installed' in env and - int_no_digits and - not monetary and - isinstance(value, float) and - dp): - prec = env['decimal.precision'].precision_get(dp) - if not float_compare(value, int(value), precision_digits=prec): - digits = 0 - dp = False - res = formatLang_original( - self, value, digits=digits, grouping=grouping, monetary=monetary, - dp=dp, currency_obj=currency_obj) - return res - -misc.formatLang = formatLang diff --git a/purchase_stock_usability/__init__.py b/purchase_stock_usability/__init__.py new file mode 100644 index 0000000..370f577 --- /dev/null +++ b/purchase_stock_usability/__init__.py @@ -0,0 +1 @@ +from . import purchase diff --git a/purchase_stock_usability/__manifest__.py b/purchase_stock_usability/__manifest__.py new file mode 100644 index 0000000..0739b6d --- /dev/null +++ b/purchase_stock_usability/__manifest__.py @@ -0,0 +1,29 @@ +# Copyright (C) 2014-2019 Akretion (http://www.akretion.com) +# @author Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Purchase Stock Usability', + 'version': '12.0.1.0.0', + 'category': 'Purchases', + 'license': 'AGPL-3', + 'summary': 'Usability improvements on purchase_stock module', + 'description': """ +Purchase Stock Usability +======================== + +Several usability improvements on the official purchase_stock module: + +Please contact Alexis de Lattre from Akretion for any help or question about this module. + """, + 'author': 'Akretion', + 'website': 'http://www.akretion.com', + 'depends': [ + 'purchase_stock', + 'purchase_usability', + ], + 'data': [ + 'stock_view.xml', + ], + 'installable': True, +} diff --git a/purchase_stock_usability/purchase.py b/purchase_stock_usability/purchase.py new file mode 100644 index 0000000..c2a8b3b --- /dev/null +++ b/purchase_stock_usability/purchase.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Copyright 2015-2019 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 + + +class PurchaseOrder(models.Model): + _inherit = 'purchase.order' + + picking_type_id = fields.Many2one(track_visibility='onchange') + incoterm_id = fields.Many2one(track_visibility='onchange') + + # inherit compute method of the field delivery_partner_id + # defined in purchase_usability + @api.depends('dest_address_id', 'picking_type_id') + def _compute_delivery_partner_id(self): + for o in self: + delivery_partner_id = False + if o.dest_address_id: + delivery_partner_id = o.dest_address_id + elif ( + o.picking_type_id.warehouse_id and + o.picking_type_id.warehouse_id.partner_id): + delivery_partner_id = o.picking_type_id.warehouse_id.partner_id + o.delivery_partner_id = delivery_partner_id diff --git a/purchase_stock_usability/stock_view.xml b/purchase_stock_usability/stock_view.xml new file mode 100644 index 0000000..8e8d395 --- /dev/null +++ b/purchase_stock_usability/stock_view.xml @@ -0,0 +1,22 @@ + + + + + + + purchase_usability.stock.picking.form + stock.picking + + + + + + + + + + diff --git a/purchase_usability/__init__.py b/purchase_usability/__init__.py index 62f29c5..6e1648e 100644 --- a/purchase_usability/__init__.py +++ b/purchase_usability/__init__.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- - from . import purchase from . import product from . import partner diff --git a/purchase_usability/__manifest__.py b/purchase_usability/__manifest__.py index b115a86..9f22069 100644 --- a/purchase_usability/__manifest__.py +++ b/purchase_usability/__manifest__.py @@ -1,19 +1,18 @@ -# -*- coding: utf-8 -*- -# Copyright (C) 2014-2017 Akretion (http://www.akretion.com) +# Copyright (C) 2014-2019 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': '10.0.0.1.0', - 'category': 'Purchase Management', + 'version': '12.0.1.0.0', + 'category': 'Purchases', 'license': 'AGPL-3', - 'summary': 'Show invoices and receptions on PO', + 'summary': 'Usability improvements on purchase module', 'description': """ -Purchase Usability Extension -============================ +Purchase Usability +================== -Display Invoices and Incoming Shipments on Purchase Order form view (in dedicated tabs). +Several usability improvements on the official purchase module: Please contact Alexis de Lattre from Akretion for any help or question about this module. """, @@ -22,7 +21,6 @@ Please contact Alexis de Lattre from Akretion for 'depends': ['purchase'], 'data': [ 'purchase_view.xml', - 'stock_view.xml', ], - 'active': False, + 'installable': True, } diff --git a/purchase_usability/partner.py b/purchase_usability/partner.py index df23f17..7d13e5f 100644 --- a/purchase_usability/partner.py +++ b/purchase_usability/partner.py @@ -1,30 +1,11 @@ -# -*- coding: utf-8 -*- -# © 2017 Akretion (Alexis de Lattre ) +# Copyright 2017-2019 Akretion France +# @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 models, fields class ResPartner(models.Model): _inherit = 'res.partner' purchase_warn = fields.Selection(track_visibility='onchange') - - # Fix an access right issue when accessing partner form without being - # a member of the purchase/User group - @api.multi - def _purchase_invoice_count(self): - poo = self.env['purchase.order'] - aio = self.env['account.invoice'] - for partner in self: - try: - partner.purchase_order_count = poo.search_count( - [('partner_id', 'child_of', partner.id)]) - except Exception: - pass - try: - partner.supplier_invoice_count = aio.search_count([ - ('partner_id', 'child_of', partner.id), - ('type', '=', 'in_invoice')]) - except Exception: - pass diff --git a/purchase_usability/product.py b/purchase_usability/product.py index 009b8cf..5e8c72b 100644 --- a/purchase_usability/product.py +++ b/purchase_usability/product.py @@ -1,5 +1,5 @@ -# -*- coding: utf-8 -*- -# © 2016 Akretion (Alexis de Lattre ) +# 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 diff --git a/purchase_usability/purchase.py b/purchase_usability/purchase.py index a07b3cb..6676eea 100644 --- a/purchase_usability/purchase.py +++ b/purchase_usability/purchase.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# © 2015-2016 Akretion (http://www.akretion.com) +# Copyright 2015-2019 Akretion France (http://www.akretion.com) # @author Alexis de Lattre # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). @@ -10,45 +10,22 @@ from odoo.tools.misc import formatLang class PurchaseOrder(models.Model): _inherit = 'purchase.order' - picking_type_id = fields.Many2one(track_visibility='onchange') 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') - incoterm_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') - # for report + # 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) - @api.multi - @api.depends('dest_address_id', 'picking_type_id') + @api.depends('dest_address_id') def _compute_delivery_partner_id(self): - for o in self: - delivery_partner_id = False - if o.dest_address_id: - delivery_partner_id = o.dest_address_id - elif ( - o.picking_type_id.warehouse_id and - o.picking_type_id.warehouse_id.partner_id): - delivery_partner_id = o.picking_type_id.warehouse_id.partner_id - o.delivery_partner_id = delivery_partner_id - - @api.multi - def button_confirm(self): - '''Reload view upon order confirmation to display the 3 qty cols''' - res = super(PurchaseOrder, self).button_confirm() - if len(self) == 1: - res = self.env['ir.actions.act_window'].for_xml_id( - 'purchase', 'purchase_form_action') - res.update({ - 'view_mode': 'form,tree,kanban,pivot,graph,calendar', - 'res_id': self.id, - 'views': False, - }) - return res + for order in self: + order.delivery_partner_id = order.dest_address_id def print_order(self): action = self.env['report'].get_action( @@ -63,17 +40,8 @@ class PurchaseOrder(models.Model): for po in self: name = po.name if po.partner_ref: - name += ' ('+po.partner_ref+')' - if po.amount_untaxed: + 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) result.append((po.id, name)) return result - - -class StockPicking(models.Model): - _inherit = 'stock.picking' - - # Field added to have a clickable link from picking to PO - purchase_id = fields.Many2one( - related='move_lines.purchase_line_id.order_id', readonly=True, - string='Purchase Order') diff --git a/purchase_usability/purchase_view.xml b/purchase_usability/purchase_view.xml index d94e373..e6589d0 100644 --- a/purchase_usability/purchase_view.xml +++ b/purchase_usability/purchase_view.xml @@ -1,6 +1,6 @@ @@ -14,7 +14,7 @@ selection @@ -38,9 +38,6 @@ purchase.order - - - - {'search_default_draft': 1, 'search_default_todo': 1} + {'search_default_draft': 1} - - usability.purchase.order.line.form - purchase.order.line - - - - {'show_purchase': True} - - - - usability.purchase.order.line.tree purchase.order.line @@ -180,42 +161,5 @@ - - - Purchase Order Lines - purchase.order.line - - [('product_id','in',active_ids), ('state', 'in', ['purchase', 'done'])] - {} - - - - product.product.purchase.button.inherit - product.product - - - -
- -
-
-
- - - purchase_usability.product.template.form - product.template - - - - - - -