From b32b3ffe2e1e505d944177693dd5c4413e9e9fe1 Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Thu, 7 Aug 2014 11:22:43 +0200 Subject: [PATCH 1/8] [FIX] sale_exception_nostock_by_line PEP8 --- sale_exception_nostock_by_line/__init__.py | 4 ++-- sale_exception_nostock_by_line/__openerp__.py | 21 ++++++++++--------- .../model/__init__.py | 4 ++-- sale_exception_nostock_by_line/model/sale.py | 6 +++--- 4 files changed, 18 insertions(+), 17 deletions(-) diff --git a/sale_exception_nostock_by_line/__init__.py b/sale_exception_nostock_by_line/__init__.py index cb599d605f0..b58458b0775 100644 --- a/sale_exception_nostock_by_line/__init__.py +++ b/sale_exception_nostock_by_line/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Joel Grand-Guillaume # Copyright 2013 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import model diff --git a/sale_exception_nostock_by_line/__openerp__.py b/sale_exception_nostock_by_line/__openerp__.py index 2b7f3ed265f..bf1c2af8af9 100644 --- a/sale_exception_nostock_by_line/__openerp__.py +++ b/sale_exception_nostock_by_line/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Joel Grand-Guillaume # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# {'name': 'Sale No stock by line', 'version': '0.1', @@ -31,18 +31,19 @@ Sale No stock by line ===================== -This module depends on both sale_exception_nostock and sale_sourced_by_line and make the -exception occure based on the location of each line. +This module depends on both sale_exception_nostock and sale_sourced_by_line and +make the exception occure based on the location of each line. -The principle of the no-stock exception is to raise a warning when no enough stock are -gound in the location of the SO shop. This module make the warning occure for every line -location instead of looking at the shop location for all line. +The principle of the no-stock exception is to raise a warning when no enough +stock are gound in the location of the SO shop. This module make the warning +occure for every line location instead of looking at the shop location for all +line. """, 'depends': [ - 'sale_exception_nostock', - 'sale_sourced_by_line', - ], + 'sale_exception_nostock', + 'sale_sourced_by_line', + ], 'demo': [], 'data': [], 'test': [], diff --git a/sale_exception_nostock_by_line/model/__init__.py b/sale_exception_nostock_by_line/model/__init__.py index d65199e72a4..d5d7f376f0f 100644 --- a/sale_exception_nostock_by_line/model/__init__.py +++ b/sale_exception_nostock_by_line/model/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import sale diff --git a/sale_exception_nostock_by_line/model/sale.py b/sale_exception_nostock_by_line/model/sale.py index b215e3866fa..ab0bd28874c 100644 --- a/sale_exception_nostock_by_line/model/sale.py +++ b/sale_exception_nostock_by_line/model/sale.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Joel Grand-Guillaume # Copyright 2013 Camptocamp SA @@ -17,11 +17,12 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm class sale_order_line(orm.Model): + """Override the _get_line_location method to look at the right one for every line instead of taking the shop location for all.""" @@ -29,4 +30,3 @@ class sale_order_line(orm.Model): def _get_line_location(self, line_br, context=None): return line_br.location_id.id - From 18afcd3004903fd3d7bc9b87350b45c6f71cdc55 Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Thu, 7 Aug 2014 11:24:58 +0200 Subject: [PATCH 2/8] [FIX] sale_line_description PEP8 --- sale_line_description/__init__.py | 6 +++--- sale_line_description/__openerp__.py | 4 ++-- sale_line_description/res_config.py | 4 ++-- sale_line_description/sale.py | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sale_line_description/__init__.py b/sale_line_description/__init__.py index 4ce46f8ba31..ddf9d415765 100644 --- a/sale_line_description/__init__.py +++ b/sale_line_description/__init__.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright (C) 2013 Agile Business Group sagl -# () +# () # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# import res_config import sale diff --git a/sale_line_description/__openerp__.py b/sale_line_description/__openerp__.py index ba7ec16cd98..850b701d49f 100644 --- a/sale_line_description/__openerp__.py +++ b/sale_line_description/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright (C) 2013 Agile Business Group sagl # () @@ -18,7 +18,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# { 'name': "Sale line description", 'version': '0.1', diff --git a/sale_line_description/res_config.py b/sale_line_description/res_config.py index e3b804006a0..fa70d66b9e0 100644 --- a/sale_line_description/res_config.py +++ b/sale_line_description/res_config.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright (C) 2013 Agile Business Group sagl # () @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import fields, osv diff --git a/sale_line_description/sale.py b/sale_line_description/sale.py index 43a12b004d3..07d52a66c67 100644 --- a/sale_line_description/sale.py +++ b/sale_line_description/sale.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright (C) 2013 Agile Business Group sagl # () @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm From e762efedd6db1dff8ac81bc29c686fb91abb4ef3 Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Thu, 7 Aug 2014 11:38:15 +0200 Subject: [PATCH 3/8] [FIX] product_special_type_sale PEP8 --- product_special_type_sale/__init__.py | 4 +- product_special_type_sale/__openerp__.py | 37 ++++---- product_special_type_sale/sale.py | 107 +++++++++++++++-------- 3 files changed, 90 insertions(+), 58 deletions(-) diff --git a/product_special_type_sale/__init__.py b/product_special_type_sale/__init__.py index deb8bc07026..40e180190f7 100644 --- a/product_special_type_sale/__init__.py +++ b/product_special_type_sale/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2012 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# import sale diff --git a/product_special_type_sale/__openerp__.py b/product_special_type_sale/__openerp__.py index 55b786ebe4a..b3c1f5e4900 100644 --- a/product_special_type_sale/__openerp__.py +++ b/product_special_type_sale/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2012 Camptocamp SA @@ -17,24 +17,25 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# { - "name" : "Product Special Type on Sale", - "version" : "1.0", - "author" : "Camptocamp", - "license": "AGPL-3", - "category" : "Hidden/Links", - "description": -""" -According to the products special types (discount, advance, delivery), compute totals on sales. + "name": "Product Special Type on Sale", + "version": "1.0", + "author": "Camptocamp", + "license": "AGPL-3", + "category": "Hidden/Links", + "description": + """ +According to the products special types (discount, advance, delivery), compute +totals on sales. """, - "website": "http://camptocamp.com", - "depends" : ['sale', - 'product_special_type',], - "init_xml" : [], - "demo_xml" : [], - "update_xml" : [], - "active": False, - 'installable': False + "website": "http://camptocamp.com", + "depends": ['sale', + 'product_special_type', ], + "init_xml": [], + "demo_xml": [], + "update_xml": [], + "active": False, + 'installable': False } diff --git a/product_special_type_sale/sale.py b/product_special_type_sale/sale.py index 3b86a7c68fb..88ca70ce64e 100644 --- a/product_special_type_sale/sale.py +++ b/product_special_type_sale/sale.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2012 Camptocamp SA @@ -17,71 +17,99 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# import decimal_precision as dp from operator import add from osv import osv, fields + class sale_order(osv.osv): _inherit = 'sale.order' def _special_lines(self, cr, uid, ids, name, args, context=None): - """ Compute Discount and Advances amounts (sum of all the products of these types) + """ Compute Discount and Advances amounts (sum of all the products of + these types) """ res = {} product_to_fields = {'discount': 'extra_discount_amount', 'advance': 'advance_amount', 'delivery': 'delivery_amount'} for order in self.browse(cr, uid, ids, context=context): - res[order.id] = dict((field, 0.0) for field in product_to_fields.values()) + res[order.id] = dict((field, 0.0) + for field in product_to_fields.values()) for special_type, field in product_to_fields.iteritems(): - res[order.id][field] = reduce(add, - [line.price_subtotal - for line in order.order_line - if line.product_id - and line.product_id.special_type == special_type], 0.0) + res[order.id][field] = reduce( + add, [ + line.price_subtotal for line in order.order_line + if line.product_id + and line.product_id.special_type == special_type + ], 0.0) return res - # super does not work for store function triggers as self is not the current object + # super does not work for store function triggers as self is not the + # current object # we have to redefine the methods in this class def _get_order(self, cr, uid, ids, context=None): result = {} - for line in self.pool.get('sale.order.line').browse(cr, uid, ids, context=context): + for line in self.pool.get('sale.order.line').browse( + cr, uid, ids, context=context + ): result[line.order_id.id] = True return result.keys() _columns = { - 'extra_discount_amount': fields.function(_special_lines, method=True, - digits_compute=dp.get_precision('Product Price'), - string='Extra-Discount', - help="The amount of extra-discount", - multi='special_lines', - store = { - 'sale.order': (lambda self, cr, uid, ids, c=None: ids, ['order_line'], 10), - 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty', 'product_id'], 10), + 'extra_discount_amount': fields.function( + _special_lines, method=True, + digits_compute=dp.get_precision( + 'Product Price'), + string='Extra-Discount', + help="The amount of extra-discount", + multi='special_lines', + store={ + 'sale.order': ( + lambda self, cr, uid, ids, c=None: ids, ['order_line'], 10 + ), + 'sale.order.line': (_get_order, [ + 'price_unit', 'tax_id', 'discount', + 'product_uom_qty', 'product_id' + ], 10), + }), + 'advance_amount': fields.function( + _special_lines, method=True, + digits_compute=dp.get_precision( + 'Product Price'), + string='Advance', + help="The amount of advances", + multi='special_lines', + store={ + 'sale.order': ( + lambda self, cr, uid, ids, c=None: ids, ['order_line'], 10 + ), + 'sale.order.line': (_get_order, [ + 'price_unit', 'tax_id', 'discount', + 'product_uom_qty', 'product_id' + ], 10), }), - 'advance_amount': fields.function(_special_lines, method=True, - digits_compute=dp.get_precision('Product Price'), - string='Advance', - help="The amount of advances", - multi='special_lines', - store = { - 'sale.order': (lambda self, cr, uid, ids, c=None: ids, ['order_line'], 10), - 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty', 'product_id'], 10), + 'delivery_amount': fields.function( + _special_lines, method=True, + digits_compute=dp.get_precision( + 'Product Price'), + string='Delivery Costs', + help="The amount of delivery costs", + multi='special_lines', + store={ + 'sale.order': ( + lambda self, cr, uid, ids, c=None: ids, ['order_line'], 10 + ), + 'sale.order.line': (_get_order, [ + 'price_unit', 'tax_id', 'discount', + 'product_uom_qty', 'product_id' + ], 10), }), - 'delivery_amount': fields.function(_special_lines, method=True, - digits_compute=dp.get_precision('Product Price'), - string='Delivery Costs', - help="The amount of delivery costs", - multi='special_lines', - store = { - 'sale.order': (lambda self, cr, uid, ids, c=None: ids, ['order_line'], 10), - 'sale.order.line': (_get_order, ['price_unit', 'tax_id', 'discount', 'product_uom_qty', 'product_id'], 10), - }), } sale_order() @@ -93,12 +121,15 @@ class sale_order_line(osv.osv): def _hidden_in_report(self, cr, uid, ids, name, args, context=None): """ - Discount and Advances are hidden in the report template and displayed as a sum in the totals + Discount and Advances are hidden in the report template and displayed + as a sum in the totals """ res = {} for line in self.browse(cr, uid, ids, context=context): res[line.id] = False - if line.product_id and line.product_id.special_type in ('discount', 'advance', 'delivery'): + if line.product_id and line.product_id.special_type in ( + 'discount', 'advance', 'delivery' + ): res[line.id] = True return res From c9376f497fd556286f106afe4786fcd61f027fe5 Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Thu, 7 Aug 2014 11:39:50 +0200 Subject: [PATCH 4/8] [FIX] account_invoice_reorder_lines/__openerp__.py PEP8 --- account_invoice_reorder_lines/__openerp__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/account_invoice_reorder_lines/__openerp__.py b/account_invoice_reorder_lines/__openerp__.py index 7ddd70ea01b..9e2c90bfe5d 100644 --- a/account_invoice_reorder_lines/__openerp__.py +++ b/account_invoice_reorder_lines/__openerp__.py @@ -24,7 +24,8 @@ 'version': '0.1', 'category': 'Generic Modules/Accounting', 'description': ''' -Provide a new field on the invoice line form, allowing to manage the lines order. +Provide a new field on the invoice line form, allowing to manage the lines +order. ''', 'author': 'Tiny', 'website': 'http://www.openerp.com', From c46013def77c8c0a8d1eccdb23619dbe0c6376d0 Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Thu, 7 Aug 2014 12:23:36 +0200 Subject: [PATCH 5/8] [FIX] repository PEP8 --- account_invoice_reorder_lines/__init__.py | 4 +- account_invoice_reorder_lines/__openerp__.py | 4 +- account_invoice_reorder_lines/invoice.py | 4 +- mail_quotation/__init__.py | 9 +- mail_quotation/__openerp__.py | 36 +-- partner_prepayment/__init__.py | 4 +- partner_prepayment/__openerp__.py | 4 +- partner_prepayment/model/__init__.py | 4 +- partner_prepayment/model/res_partner.py | 7 +- partner_prepayment/model/sale.py | 4 +- pricelist_share_companies/__init__.py | 4 +- pricelist_share_companies/__openerp__.py | 49 ++-- pricelist_share_companies/company.py | 19 +- pricelist_share_companies/pricelist.py | 48 ++-- product_customer_code_sale/__init__.py | 4 +- product_customer_code_sale/__openerp__.py | 24 +- product_customer_code_sale/sale.py | 6 +- product_special_type/__init__.py | 4 +- product_special_type/__openerp__.py | 40 +-- product_special_type/product.py | 9 +- product_special_type_invoice/__init__.py | 4 +- product_special_type_invoice/__openerp__.py | 37 +-- product_special_type_invoice/invoice.py | 112 +++++--- product_special_type_sale/sale.py | 14 +- purchase_order_reorder_lines/__init__.py | 4 +- purchase_order_reorder_lines/__openerp__.py | 13 +- purchase_order_reorder_lines/purchase.py | 28 +- sale_cancel_reason/__init__.py | 4 +- sale_cancel_reason/__openerp__.py | 4 +- sale_cancel_reason/model/__init__.py | 4 +- sale_cancel_reason/model/sale.py | 4 +- sale_cancel_reason/wizard/__init__.py | 4 +- sale_cancel_reason/wizard/cancel_reason.py | 5 +- sale_condition_text/__init__.py | 8 +- sale_condition_text/__openerp__.py | 29 +- sale_condition_text/account_invoice.py | 18 +- sale_condition_text/condition.py | 30 +- sale_condition_text/sale_order.py | 40 +-- sale_delivery_term/__init__.py | 6 +- sale_delivery_term/__openerp__.py | 23 +- sale_delivery_term/sale.py | 261 +++++++++++------- sale_dropshipping/__init__.py | 4 +- sale_dropshipping/__openerp__.py | 22 +- sale_dropshipping/product.py | 33 ++- sale_dropshipping/purchase.py | 36 ++- sale_dropshipping/sale.py | 129 +++++---- sale_exception_nostock/__init__.py | 4 +- sale_exception_nostock/__openerp__.py | 7 +- sale_exception_nostock/model/__init__.py | 4 +- sale_exception_nostock/model/sale.py | 34 ++- sale_exception_nostock/test/__init__.py | 4 +- sale_exception_nostock/test/test_utils.py | 8 +- sale_exceptions/__init__.py | 7 +- sale_exceptions/__openerp__.py | 16 +- sale_exceptions/sale.py | 26 +- sale_exceptions/wizard/__init__.py | 7 +- .../wizard/sale_exception_confirm.py | 4 +- sale_fiscal_position_update/__init__.py | 4 +- sale_fiscal_position_update/__openerp__.py | 12 +- sale_fiscal_position_update/sale.py | 6 +- sale_jit_on_services/__init__.py | 4 +- sale_jit_on_services/__openerp__.py | 4 +- sale_jit_on_services/procurement.py | 6 +- sale_journal_shop/__init__.py | 4 +- sale_journal_shop/__openerp__.py | 6 +- sale_journal_shop/sale.py | 4 +- sale_multi_picking/__init__.py | 6 +- sale_multi_picking/__openerp__.py | 19 +- sale_multi_picking/sale.py | 39 ++- sale_order_force_number/__init__.py | 6 +- sale_order_force_number/__openerp__.py | 20 +- sale_quotation_number/__init__.py | 6 +- sale_quotation_number/__openerp__.py | 8 +- sale_quotation_number/sale_quotation.py | 4 +- sale_sourced_by_line/__init__.py | 4 +- sale_sourced_by_line/__openerp__.py | 4 +- sale_sourced_by_line/model/__init__.py | 4 +- sale_sourced_by_line/model/sale.py | 4 +- .../__init__.py | 4 +- .../__openerp__.py | 4 +- .../sale_stock.py | 44 +-- sale_validity/__init__.py | 4 +- sale_validity/__openerp__.py | 10 +- sale_validity/model/__init__.py | 4 +- sale_validity/model/company.py | 6 +- sale_validity/model/sale_order.py | 8 +- stock_picking_reorder_lines/__init__.py | 4 +- stock_picking_reorder_lines/__openerp__.py | 7 +- stock_picking_reorder_lines/stock.py | 16 +- 89 files changed, 921 insertions(+), 648 deletions(-) diff --git a/account_invoice_reorder_lines/__init__.py b/account_invoice_reorder_lines/__init__.py index 2f07f64df0a..fdb295f1215 100644 --- a/account_invoice_reorder_lines/__init__.py +++ b/account_invoice_reorder_lines/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). @@ -18,5 +18,5 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import invoice diff --git a/account_invoice_reorder_lines/__openerp__.py b/account_invoice_reorder_lines/__openerp__.py index 9e2c90bfe5d..224f1043604 100644 --- a/account_invoice_reorder_lines/__openerp__.py +++ b/account_invoice_reorder_lines/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). @@ -18,7 +18,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# { 'name': 'Invoice lines with sequence number', 'version': '0.1', diff --git a/account_invoice_reorder_lines/invoice.py b/account_invoice_reorder_lines/invoice.py index 8c2ad45922e..a81f38029e1 100644 --- a/account_invoice_reorder_lines/invoice.py +++ b/account_invoice_reorder_lines/invoice.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). @@ -18,7 +18,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm diff --git a/mail_quotation/__init__.py b/mail_quotation/__init__.py index 5dcefef281c..d7ac47a542a 100644 --- a/mail_quotation/__init__.py +++ b/mail_quotation/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# +# +# # OpenERP, Open Source Management Solution # Copyright (C) 2012 Savoir-faire Linux (). # @@ -15,7 +15,6 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . +# # -############################################################################## - diff --git a/mail_quotation/__openerp__.py b/mail_quotation/__openerp__.py index 46dcf7ec277..ae10b2b14aa 100644 --- a/mail_quotation/__openerp__.py +++ b/mail_quotation/__openerp__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# +# +# # OpenERP, Open Source Management Solution # Copyright (C) 2012 Savoir-faire Linux (). # @@ -15,26 +15,26 @@ # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . +# along with this program. If not, see . +# # -############################################################################## { - "name" : "Mail quotation", - "version" : "0.1", - "author" : "Savoir-faire Linux", - "website" : "http://www.savoirfairelinux.com", - "license" : "AGPL-3", - "category" : "Mail", - "description" : """ -This module adds a server action, an email template and a button on the sales order form to -send quotation by email. + "name": "Mail quotation", + "version": "0.1", + "author": "Savoir-faire Linux", + "website": "http://www.savoirfairelinux.com", + "license": "AGPL-3", + "category": "Mail", + "description": """ +This module adds a server action, an email template and a button on the +sales order form to send quotation by email. """, - "images" : [], - "depends" : ["sale"], - "demo" : [], - "test" : [], - "data" : [ + "images": [], + "depends": ["sale"], + "demo": [], + "test": [], + "data": [ "quotation_action_data.xml", "sale_order_view.xml", ], diff --git a/partner_prepayment/__init__.py b/partner_prepayment/__init__.py index 643bee7abed..c09d73c4161 100644 --- a/partner_prepayment/__init__.py +++ b/partner_prepayment/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import model diff --git a/partner_prepayment/__openerp__.py b/partner_prepayment/__openerp__.py index d18f3c7e5f0..0770419dd4a 100644 --- a/partner_prepayment/__openerp__.py +++ b/partner_prepayment/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright 2013 Camptocamp SA # @@ -16,7 +16,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# {'name': 'Partner Prepayment', 'version': '1.0', diff --git a/partner_prepayment/model/__init__.py b/partner_prepayment/model/__init__.py index d725ac0f431..2d6615e3ee6 100644 --- a/partner_prepayment/model/__init__.py +++ b/partner_prepayment/model/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import res_partner from . import sale diff --git a/partner_prepayment/model/res_partner.py b/partner_prepayment/model/res_partner.py index 2ae0c243413..678252a9bbb 100644 --- a/partner_prepayment/model/res_partner.py +++ b/partner_prepayment/model/res_partner.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm, fields @@ -33,6 +33,7 @@ class res_partner(orm.Model): } def _commercial_fields(self, cr, uid, context=None): - fields = super(res_partner, self)._commercial_fields(cr, uid, context=context) + fields = super(res_partner, self)._commercial_fields( + cr, uid, context=context) fields.append('use_prepayment') return fields diff --git a/partner_prepayment/model/sale.py b/partner_prepayment/model/sale.py index 5bd80851f3c..ce3da40298e 100644 --- a/partner_prepayment/model/sale.py +++ b/partner_prepayment/model/sale.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm diff --git a/pricelist_share_companies/__init__.py b/pricelist_share_companies/__init__.py index 64678f58866..aabd6e9da63 100644 --- a/pricelist_share_companies/__init__.py +++ b/pricelist_share_companies/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Joël Grand-Guillaume # Copyright 2010 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# import pricelist import company diff --git a/pricelist_share_companies/__openerp__.py b/pricelist_share_companies/__openerp__.py index 9275e6db407..8f730d21132 100644 --- a/pricelist_share_companies/__openerp__.py +++ b/pricelist_share_companies/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Joël Grand-Guillaume # Copyright 2010 Camptocamp SA @@ -17,33 +17,42 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# { - 'name' : 'Share pricelist between compagnies, not product', - 'version' : '1.0', - 'category' : 'Generic Modules/Projects & Services', - 'description': -''' -In OpenERP, product prices (cost, list) are expressed in the currency of the price_type (by default the same than your company currency). + 'name': 'Share pricelist between compagnies, not product', + 'version': '1.0', + 'category': 'Generic Modules/Projects & Services', + 'description': + ''' +In OpenERP, product prices (cost, list) are expressed in the currency of +the price_type (by default the same than your company currency). -The idea here is to have the same products between compagnies (with each one their own currency through different price_type and different costs) but -only one pricelist for all. For that purpose, we add a company_id on price_type object and a rule to separate them for each company. This way, -the price computation of pricelist will take the right price_type currency as based price. +The idea here is to have the same products between compagnies (with each one +their own currency through different price_type and different costs) but +only one pricelist for all. For that purpose, we add a company_id on price_type +object and a rule to separate them for each company. This way, +the price computation of pricelist will take the right price_type currency as +based price. Concretely, to have a different cost price for a second company, you have to : - Create a new standard price on product.template - - Create a new 'Price Type' on this new field, with the desired currency and assigned to the new currency + - Create a new 'Price Type' on this new field, with the desired currency and + assigned to the new currency - Assign the existing 'Cost Price' to your main company - - On the setup of each company, in the 'Configuration''s Tab, select the product field used for the cost + - On the setup of each company, in the 'Configuration''s Tab, select + the product field used for the cost -The Price Type used is the first one found for the cost field configured on the company. To ensure the right Price Type -is selected, you have to put the company on the Price Types, and according to the security rule created, you will have access +The Price Type used is the first one found for the cost field configured on +the company. To ensure the right Price Type +is selected, you have to put the company on the Price Types, and according to +the security rule created, you will have access only to the right Price Type. Example: -I create a product A. it has 2 fields for cost prices : Cost Price and Cost Price CH +I create a product A. it has 2 fields for cost prices : Cost Price and +Cost Price CH Price type Sale company A : Cost Price / EUR Price type Sale company B : Cost Price CH / CHF @@ -56,15 +65,15 @@ ''', - 'author' : 'Camptocamp', + 'author': 'Camptocamp', 'website': 'http://camptocamp.com', - 'depends' : ['product',], - 'data' : [ + 'depends': ['product', ], + 'data': [ 'pricelist_view.xml', 'company_view.xml', 'security/pricelist_security.xml', ], - 'demo' : [], + 'demo': [], 'test': [], 'installable': True, 'auto_install': False, diff --git a/pricelist_share_companies/company.py b/pricelist_share_companies/company.py index fd5c0922243..8b22c0d5795 100644 --- a/pricelist_share_companies/company.py +++ b/pricelist_share_companies/company.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2011 Camptocamp SA @@ -17,10 +17,12 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm, fields + class ResCompany(orm.Model): + '''Override company to add the fields to use for the prices''' _inherit = 'res.company' @@ -29,8 +31,11 @@ def _price_field_get(self, cr, uid, context=None): context = {} mf = self.pool.get('ir.model.fields') ids = mf.search(cr, uid, - [('model','in', (('product.product'),('product.template'))), - ('ttype','=','float')], + [ + ('model', 'in', ( + ('product.product'), ('product.template') + )), + ('ttype', '=', 'float')], context=context) res = [(False, '')] for field in mf.browse(cr, uid, ids, context=context): @@ -38,9 +43,11 @@ def _price_field_get(self, cr, uid, context=None): return res _columns = { - 'standard_price_field': fields.selection(_price_field_get, 'Field for Cost Price', size=32, + 'standard_price_field': fields.selection( + _price_field_get, 'Field for Cost Price', size=32, required=True, - help="If a field is selected, it will be used instead of the \"standard_price\" field" + help="If a field is selected, it will be used instead of the " + "\"standard_price\" field" "on the search of a Cost Price's Price Type.") } diff --git a/pricelist_share_companies/pricelist.py b/pricelist_share_companies/pricelist.py index f2a3a61355c..fa5036a38cd 100644 --- a/pricelist_share_companies/pricelist.py +++ b/pricelist_share_companies/pricelist.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2011 Camptocamp SA @@ -17,36 +17,47 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm, fields + class PriceType(orm.Model): _inherit = 'product.price.type' _columns = { - 'company_id' : fields.many2one('res.company', 'Company'), - } + 'company_id': fields.many2one('res.company', 'Company'), + } def _check_unicity_per_company(self, cr, uid, ids, context=None): for price_type in self.browse(cr, uid, ids, context=context): if price_type.company_id: - cr.execute('SELECT id FROM product_price_type WHERE id != %s AND field = %s and company_id = %s', - (price_type.id, price_type.field, price_type.company_id.id)) + cr.execute( + 'SELECT id FROM product_price_type WHERE id != %s AND ' + 'field = %s and company_id = %s', + (price_type.id, price_type.field, price_type.company_id.id) + ) res = cr.fetchall() if res: return False return True _constraints = [ - (_check_unicity_per_company, 'You can not create two price types with same field and same company.', ['company_id', 'field']), + (_check_unicity_per_company, + 'You can not create two price types with same field and same ' + 'company.', ['company_id', 'field']), ] - def search(self, cr, uid, args, offset=0, limit=None, order=None, context=None, count=False): + def search( + self, cr, uid, args, offset=0, limit=None, order=None, context=None, + count=False + ): """ Inherit the default search of price types to replace search of list_price and standard_price by another field according to company This is useful to create a field on the product, for example - list_price_company_x, which is the price of the product for the company_x. - In the configuration of the company, choose to use this field instead of the - list_price, this method will now return the good list_price according to the setup""" + list_price_company_x, which is the price of the product for the + company_x. + In the configuration of the company, choose to use this field instead + of the list_price, this method will now return the good list_price + according to the setup""" def replace_args(search_args, ptype, company): if not filter(lambda x: x[2] == ptype, search_args): @@ -55,17 +66,22 @@ def replace_args(search_args, ptype, company): if getattr(company, "%s_field" % ptype): operator = filter(lambda x: x[0] == 'field', search_args)[0][1] value = filter(lambda x: x[0] == 'field', search_args)[0][2] - #get the other arguments of the search + # get the other arguments of the search search_args = filter(lambda x: x[0] != 'field', search_args) # replace the price list by the one configured on the company - search_args += [('field', operator, getattr(company, "%s_field" % value))] + search_args += [ + ('field', operator, getattr(company, "%s_field" % value))] return search_args args1 = args[:] - if filter(lambda x: x[0] == 'field' and x[2] == 'standard_price', args): - company = self.pool.get('res.users').browse(cr, uid, uid).company_id + if filter( + lambda x: x[0] == 'field' and x[2] == 'standard_price', args + ): + company = self.pool.get('res.users').browse( + cr, uid, uid).company_id args1 = replace_args(args1, 'standard_price', company) - return super(PriceType, self).search(cr, uid, args1, offset, limit, order, context=context, count=count) + return super(PriceType, self).search( + cr, uid, args1, offset, limit, order, context=context, count=count) # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/product_customer_code_sale/__init__.py b/product_customer_code_sale/__init__.py index 32ce6c86a72..38351a65f4f 100644 --- a/product_customer_code_sale/__init__.py +++ b/product_customer_code_sale/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright (C) 2013 Agile Business Group sagl () # Author: Nicola Malcontenti @@ -17,5 +17,5 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import sale diff --git a/product_customer_code_sale/__openerp__.py b/product_customer_code_sale/__openerp__.py index 59367b7a2cb..85743e7f0b7 100644 --- a/product_customer_code_sale/__openerp__.py +++ b/product_customer_code_sale/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright (C) 2013 Agile Business Group sagl () # Author: Nicola Malcontenti @@ -17,14 +17,14 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# { - "name" : "Product Customer code on sale", - "version" : "1.0", - "author" : "Agile Business Group", - "website" : "http://www.agilebg.com", - "category" : "Sales Management", - "depends" : [ + "name": "Product Customer code on sale", + "version": "1.0", + "author": "Agile Business Group", + "website": "http://www.agilebg.com", + "category": "Sales Management", + "depends": [ 'base', 'product', 'sale', @@ -35,10 +35,10 @@ this module loads in every sale order line the customer code defined in the product, """, - "demo" : [], - "data" : [ + "demo": [], + "data": [ 'sale_view.xml', ], - 'installable' : True, - 'active' : False, + 'installable': True, + 'active': False, } diff --git a/product_customer_code_sale/sale.py b/product_customer_code_sale/sale.py index cb6361f72b9..5844f6a7aca 100644 --- a/product_customer_code_sale/sale.py +++ b/product_customer_code_sale/sale.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright (C) 2013 Agile Business Group sagl () # Author: Nicola Malcontenti @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import fields, orm @@ -39,7 +39,7 @@ def _get_product_customer_code( code_ids = product_customer_code_obj.search(cr, uid, [ ('product_id', '=', product.id), ('partner_id', '=', partner.id), - ], limit=1, context=context) + ], limit=1, context=context) if code_ids: code = product_customer_code_obj.browse( cr, uid, diff --git a/product_special_type/__init__.py b/product_special_type/__init__.py index 3b4e95b9c3a..114fd03d5df 100644 --- a/product_special_type/__init__.py +++ b/product_special_type/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2012 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# import product diff --git a/product_special_type/__openerp__.py b/product_special_type/__openerp__.py index 775df457fa6..acc9039e785 100644 --- a/product_special_type/__openerp__.py +++ b/product_special_type/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2012 Camptocamp SA @@ -17,32 +17,34 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# { - "name" : "Product Special Types", - "version" : "1.0", - "author" : "Camptocamp", - "license": "AGPL-3", - "category" : "Sales", - "description": -""" + "name": "Product Special Types", + "version": "1.0", + "author": "Camptocamp", + "license": "AGPL-3", + "category": "Sales", + "description": + """ Add a special type selection on products. Let create products as : - Global Discount - Delivery Costs - Advance -It add fields on the sale order and the invoice with the totals of each product types. -These fields can be used on reports to display the amounts for discounts / advances / fees separately. +It add fields on the sale order and the invoice with the totals of each +product types. +These fields can be used on reports to display the amounts for +discounts / advances / fees separately. """, - "website": "http://camptocamp.com", - "depends" : ['base', - 'product',], - "init_xml" : [], - "demo_xml" : [], - "update_xml" : ['product_view.xml'], - "active": False, - 'installable': False + "website": "http://camptocamp.com", + "depends": ['base', + 'product', ], + "init_xml": [], + "demo_xml": [], + "update_xml": ['product_view.xml'], + "active": False, + 'installable': False } diff --git a/product_special_type/product.py b/product_special_type/product.py index 31f3e692572..b9a90b80158 100644 --- a/product_special_type/product.py +++ b/product_special_type/product.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2012 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from osv import osv, fields @@ -32,7 +32,10 @@ class product_template(osv.osv): ('delivery', 'Delivery Costs'), ('', '')], string='Special Type', - help='Special products will not be displayed on invoices printed reports but will be summed in the totals.'), + help='Special products will not be ' + 'displayed on invoices printed ' + 'reports but will be summed in ' + 'the totals.'), } product_template() diff --git a/product_special_type_invoice/__init__.py b/product_special_type_invoice/__init__.py index 25da865208c..87766757871 100644 --- a/product_special_type_invoice/__init__.py +++ b/product_special_type_invoice/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2012 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# import invoice diff --git a/product_special_type_invoice/__openerp__.py b/product_special_type_invoice/__openerp__.py index 02baacab1ba..5fbb9ae1592 100644 --- a/product_special_type_invoice/__openerp__.py +++ b/product_special_type_invoice/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2012 Camptocamp SA @@ -17,24 +17,25 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# { - "name" : "Product Special Type on Invoice", - "version" : "1.0", - "author" : "Camptocamp", - "license": "AGPL-3", - "category" : "Hidden/Links", - "description": -""" -According to the products special types (discount, advance, delivery), compute totals on invoices. + "name": "Product Special Type on Invoice", + "version": "1.0", + "author": "Camptocamp", + "license": "AGPL-3", + "category": "Hidden/Links", + "description": + """ +According to the products special types (discount, advance, delivery), +compute totals on invoices. """, - "website": "http://camptocamp.com", - "depends" : ['product_special_type', - 'account',], - "init_xml" : [], - "demo_xml" : [], - "update_xml" : [], - "active": False, - 'installable': False + "website": "http://camptocamp.com", + "depends": ['product_special_type', + 'account', ], + "init_xml": [], + "demo_xml": [], + "update_xml": [], + "active": False, + 'installable': False } diff --git a/product_special_type_invoice/invoice.py b/product_special_type_invoice/invoice.py index 6e9f21b2f47..0069c065bd5 100644 --- a/product_special_type_invoice/invoice.py +++ b/product_special_type_invoice/invoice.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2012 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# import decimal_precision as dp @@ -30,59 +30,86 @@ class account_invoice(osv.osv): _inherit = "account.invoice" def _special_lines(self, cr, uid, ids, name, args, context=None): - """ Compute Discount and Advances amounts (sum of all the products of these types) + """ Compute Discount and Advances amounts (sum of all the products of + these types) """ res = {} - # mapping where keys are product special type and values are the invoice fields + # mapping where keys are product special type and values are the + # invoice fields product_to_fields = {'discount': 'extra_discount_amount', 'advance': 'advance_amount', 'delivery': 'delivery_amount'} for invoice in self.browse(cr, uid, ids, context=context): - res[invoice.id] = dict((field, 0.0) for field in product_to_fields.values()) + res[invoice.id] = dict((field, 0.0) + for field in product_to_fields.values()) for special_type, field in product_to_fields.iteritems(): - res[invoice.id][field] = reduce(add, - [line.price_subtotal - for line in invoice.invoice_line - if line.product_id - and line.product_id.special_type == special_type], 0.0) + res[invoice.id][field] = reduce( + add, + [ + line.price_subtotal + for line in invoice.invoice_line + if line.product_id + and line.product_id.special_type == special_type + ], 0.0) return res - # super does not work for store function triggers as self is not the current object + # super does not work for store function triggers as self is not the + # current object # we have to redefine the method in this class def _get_invoice_line(self, cr, uid, ids, context=None): result = {} - for line in self.pool.get('account.invoice.line').browse(cr, uid, ids, context=context): + for line in self.pool.get( + 'account.invoice.line' + ).browse(cr, uid, ids, context=context): result[line.invoice_id.id] = True return result.keys() _columns = { - 'extra_discount_amount': fields.function(_special_lines, - method=True, - digits_compute=dp.get_precision('Account'), - string='Extra Discount', - multi='special_lines', - store={ - 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20), - 'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount','invoice_id', 'product_id'], 20), - }), - 'advance_amount': fields.function(_special_lines, - method=True, - digits_compute=dp.get_precision('Account'), - string='Advance', - multi='special_lines', - store={ - 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20), - 'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount','invoice_id', 'product_id'], 20), - }), - 'delivery_amount': fields.function(_special_lines, - method=True, - digits_compute=dp.get_precision('Account'), - string='Delivery Costs', - multi='special_lines', - store={ - 'account.invoice': (lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20), - 'account.invoice.line': (_get_invoice_line, ['price_unit','invoice_line_tax_id','quantity','discount','invoice_id', 'product_id'], 20), - }), + 'extra_discount_amount': fields.function( + _special_lines, + method=True, + digits_compute=dp.get_precision('Account'), + string='Extra Discount', + multi='special_lines', + store={ + 'account.invoice': ( + lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20 + ), + 'account.invoice.line': (_get_invoice_line, [ + 'price_unit', 'invoice_line_tax_id', 'quantity', + 'discount', 'invoice_id', 'product_id' + ], 20), + }), + 'advance_amount': fields.function( + _special_lines, + method=True, + digits_compute=dp.get_precision('Account'), + string='Advance', + multi='special_lines', + store={ + 'account.invoice': ( + lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20 + ), + 'account.invoice.line': (_get_invoice_line, [ + 'price_unit', 'invoice_line_tax_id', 'quantity', + 'discount', 'invoice_id', 'product_id' + ], 20), + }), + 'delivery_amount': fields.function( + _special_lines, + method=True, + digits_compute=dp.get_precision('Account'), + string='Delivery Costs', + multi='special_lines', + store={ + 'account.invoice': ( + lambda self, cr, uid, ids, c={}: ids, ['invoice_line'], 20 + ), + 'account.invoice.line': (_get_invoice_line, [ + 'price_unit', 'invoice_line_tax_id', 'quantity', + 'discount', 'invoice_id', 'product_id' + ], 20), + }), } account_invoice() @@ -94,12 +121,15 @@ class account_invoice_line(osv.osv): def _hidden_in_report(self, cr, uid, ids, name, args, context=None): """ - Discount and Advances are hidden in the report template and displayed as a sum in the totals + Discount and Advances are hidden in the report template and displayed + as a sum in the totals """ res = {} for line in self.browse(cr, uid, ids, context=context): res[line.id] = False - if line.product_id and line.product_id.special_type in ('discount', 'advance', 'delivery'): + if line.product_id and line.product_id.special_type in ( + 'discount', 'advance', 'delivery' + ): res[line.id] = True return res diff --git a/product_special_type_sale/sale.py b/product_special_type_sale/sale.py index 88ca70ce64e..a0f7997a282 100644 --- a/product_special_type_sale/sale.py +++ b/product_special_type_sale/sale.py @@ -46,7 +46,7 @@ def _special_lines(self, cr, uid, ids, name, args, context=None): line.price_subtotal for line in order.order_line if line.product_id and line.product_id.special_type == special_type - ], 0.0) + ], 0.0) return res @@ -72,11 +72,11 @@ def _get_order(self, cr, uid, ids, context=None): store={ 'sale.order': ( lambda self, cr, uid, ids, c=None: ids, ['order_line'], 10 - ), + ), 'sale.order.line': (_get_order, [ 'price_unit', 'tax_id', 'discount', 'product_uom_qty', 'product_id' - ], 10), + ], 10), }), 'advance_amount': fields.function( _special_lines, method=True, @@ -88,11 +88,11 @@ def _get_order(self, cr, uid, ids, context=None): store={ 'sale.order': ( lambda self, cr, uid, ids, c=None: ids, ['order_line'], 10 - ), + ), 'sale.order.line': (_get_order, [ 'price_unit', 'tax_id', 'discount', 'product_uom_qty', 'product_id' - ], 10), + ], 10), }), 'delivery_amount': fields.function( _special_lines, method=True, @@ -104,11 +104,11 @@ def _get_order(self, cr, uid, ids, context=None): store={ 'sale.order': ( lambda self, cr, uid, ids, c=None: ids, ['order_line'], 10 - ), + ), 'sale.order.line': (_get_order, [ 'price_unit', 'tax_id', 'discount', 'product_uom_qty', 'product_id' - ], 10), + ], 10), }), } diff --git a/purchase_order_reorder_lines/__init__.py b/purchase_order_reorder_lines/__init__.py index fed2f592a73..ef00ce3759f 100644 --- a/purchase_order_reorder_lines/__init__.py +++ b/purchase_order_reorder_lines/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Alexandre Fayolle # Copyright 2013 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import purchase diff --git a/purchase_order_reorder_lines/__openerp__.py b/purchase_order_reorder_lines/__openerp__.py index e08cb7b2083..6f6ab59d47b 100644 --- a/purchase_order_reorder_lines/__openerp__.py +++ b/purchase_order_reorder_lines/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Alexandre Fayolle # Copyright 2013 Camptocamp SA @@ -17,17 +17,22 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# { 'name': 'Purchase order lines with sequence number', 'version': '0.1', 'category': 'Purchase Management', 'description': ''' -Provide a new field on the purchase order form, allowing to manage the lines order. +Provide a new field on the purchase order form, allowing to manage the lines +order. ''', 'author': 'Camptocamp', 'website': 'http://www.camptocamp.com', - 'depends': ['purchase', 'stock_picking_reorder_lines', 'account_invoice_reorder_lines'], + 'depends': [ + 'purchase', + 'stock_picking_reorder_lines', + 'account_invoice_reorder_lines' + ], 'data': ['purchase_view.xml'], 'demo': [], 'test': [], diff --git a/purchase_order_reorder_lines/purchase.py b/purchase_order_reorder_lines/purchase.py index 75e7373d8b3..e901a5aa9a4 100644 --- a/purchase_order_reorder_lines/purchase.py +++ b/purchase_order_reorder_lines/purchase.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Alexandre Fayolle # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm, fields @@ -28,7 +28,7 @@ class purchase_order_line(orm.Model): 'sequence': fields.integer('Sequence', help="Gives the sequence of this line when " "displaying the purchase order."), - } + } _order = 'order_id desc, sequence, id' _defaults = {'sequence': 10, } @@ -40,11 +40,14 @@ class purchase_order(orm.Model): def _prepare_inv_line(self, cr, uid, account_id, order_line, context=None): res = super(purchase_order, self)._prepare_inv_line(cr, uid, account_id, - order_line, context) + order_line, + context) res['sequence'] = order_line.sequence return res - def _prepare_order_line_move(self, cr, uid, order, line, picking_id, context=None): + def _prepare_order_line_move( + self, cr, uid, order, line, picking_id, context=None + ): res = super(purchase_order, self)._prepare_order_line_move(cr, uid, order, line, @@ -59,17 +62,17 @@ class purchase_line_invoice(orm.TransientModel): def makeInvoices(self, cr, uid, ids, context=None): invoice_line_obj = self.pool.get('account.invoice.line') purchase_line_obj = self.pool.get('purchase.order.line') - res = super(purchase_line_invoice, self).makeInvoices(cr, uid, ids, context) + res = super(purchase_line_invoice, self).makeInvoices( + cr, uid, ids, context) invoice_ids = eval(res['domain'])[0][-1] # OMG :-( - invoice_line_ids = invoice_line_obj.search(cr, uid, - [('invoice_id', 'in', invoice_ids)], - context=context) + invoice_line_ids = invoice_line_obj.search( + cr, uid, [('invoice_id', 'in', invoice_ids)], context=context) for invoice_line in invoice_line_obj.browse(cr, uid, invoice_line_ids, context=context): - order_line_ids = purchase_line_obj.search(cr, uid, - [('invoice_lines', '=', invoice_line.id)], - context=context) + order_line_ids = purchase_line_obj.search( + cr, uid, [('invoice_lines', '=', invoice_line.id)], + context=context) if not order_line_ids: continue record_data = purchase_line_obj.read(cr, uid, @@ -80,4 +83,3 @@ def makeInvoices(self, cr, uid, ids, context=None): if not invoice_line.sequence: invoice_line.write({'sequence': order_line_seq}) return res - diff --git a/sale_cancel_reason/__init__.py b/sale_cancel_reason/__init__.py index a75b125293b..fc574f3cfee 100644 --- a/sale_cancel_reason/__init__.py +++ b/sale_cancel_reason/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import wizard from . import model diff --git a/sale_cancel_reason/__openerp__.py b/sale_cancel_reason/__openerp__.py index af2dd13febc..ac8cdb0345f 100644 --- a/sale_cancel_reason/__openerp__.py +++ b/sale_cancel_reason/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# {'name': 'Sale Cancel Reason', 'version': '1.0', diff --git a/sale_cancel_reason/model/__init__.py b/sale_cancel_reason/model/__init__.py index d65199e72a4..d5d7f376f0f 100644 --- a/sale_cancel_reason/model/__init__.py +++ b/sale_cancel_reason/model/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import sale diff --git a/sale_cancel_reason/model/sale.py b/sale_cancel_reason/model/sale.py index c5b9b01eb96..93e28793bf5 100644 --- a/sale_cancel_reason/model/sale.py +++ b/sale_cancel_reason/model/sale.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm, fields from openerp.tools.translate import _ diff --git a/sale_cancel_reason/wizard/__init__.py b/sale_cancel_reason/wizard/__init__.py index 5d55d1468a2..37c6d2c3f63 100644 --- a/sale_cancel_reason/wizard/__init__.py +++ b/sale_cancel_reason/wizard/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import cancel_reason diff --git a/sale_cancel_reason/wizard/cancel_reason.py b/sale_cancel_reason/wizard/cancel_reason.py index 37a5c7685f0..98800af30fa 100644 --- a/sale_cancel_reason/wizard/cancel_reason.py +++ b/sale_cancel_reason/wizard/cancel_reason.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,13 +17,14 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm, fields from openerp import netsvc class logistic_requisition_cancel(orm.TransientModel): + """ Ask a reason for the sale order cancellation.""" _name = 'sale.order.cancel' _description = __doc__ diff --git a/sale_condition_text/__init__.py b/sale_condition_text/__init__.py index e3e26ad6722..1a1987a73f4 100644 --- a/sale_condition_text/__init__.py +++ b/sale_condition_text/__init__.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -############################################################################## # -# Copyright Camptocamp SA +# +# Copyright Camptocamp SA # author nbessi # -############################################################################## +# from . import account_invoice from . import condition -from . import sale_order \ No newline at end of file +from . import sale_order diff --git a/sale_condition_text/__openerp__.py b/sale_condition_text/__openerp__.py index 249656cfc9e..501cad4fba2 100644 --- a/sale_condition_text/__openerp__.py +++ b/sale_condition_text/__openerp__.py @@ -1,20 +1,21 @@ # -*- coding: utf-8 -*- -############################################################################## # -# Copyright Camptocamp SA +# +# Copyright Camptocamp SA # author nbessi # -############################################################################## -{"name" : "Sale/invoice condition", - "version" : "1.3", - "depends" : ["sale", "account"], - "description": """Adds predefine header and footer text on sale order and invoice. - Texts are passed in the invoice when sale order is transformed into invoice""", - "author" : "Camptocamp", - "init_xml" : [], - "update_xml" : ["account_invoice_view.xml", - "sale_order_view.xml", - "condition_view.xml"], +# +{"name": "Sale/invoice condition", + "version": "1.3", + "depends": ["sale", "account"], + "description": """Adds predefine header and footer text on sale order and + invoice. +Texts are passed in the invoice when sale order is transformed into invoice""", + "author": "Camptocamp", + "init_xml": [], + "update_xml": ["account_invoice_view.xml", + "sale_order_view.xml", + "condition_view.xml"], "category": "Sale", "installable": False, - "active" : False,} + "active": False, } diff --git a/sale_condition_text/account_invoice.py b/sale_condition_text/account_invoice.py index ad5c12f8a74..d755826c78d 100644 --- a/sale_condition_text/account_invoice.py +++ b/sale_condition_text/account_invoice.py @@ -1,22 +1,26 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright Camptocamp SA # -############################################################################## +# from osv import osv, fields class AccountInvoice(osv.osv): + """Add text condition""" _inherit = "account.invoice" - _columns = {'text_condition1': fields.many2one('account.condition_text', 'Header'), - 'text_condition2': fields.many2one('account.condition_text', 'Footer'), - 'note1' : fields.text('Header'), - 'note2' : fields.text('Footer')} + _columns = { + 'text_condition1': fields.many2one('account.condition_text', 'Header'), + 'text_condition2': fields.many2one('account.condition_text', 'Footer'), + 'note1': fields.text('Header'), + 'note2': fields.text('Footer')} - def set_condition(self, cursor, uid, inv_id, cond_id, field_name, partner_id): + def set_condition( + self, cursor, uid, inv_id, cond_id, field_name, partner_id + ): cond_obj = self.pool.get('account.condition_text') return cond_obj.get_value(cursor, uid, cond_id, field_name, partner_id) diff --git a/sale_condition_text/condition.py b/sale_condition_text/condition.py index 737a0518682..d72f1692882 100644 --- a/sale_condition_text/condition.py +++ b/sale_condition_text/condition.py @@ -1,36 +1,34 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright Camptocamp SA # -############################################################################## +# from osv import osv, fields import pooler - class AccountConditionText(osv.osv): + """add info condition in the invoice""" _name = "account.condition_text" _description = "Invoice condition text" + _columns = {'name': fields.char('Condition', required=True, size=128), + 'type': fields.selection([('header', 'Header'), + ('footer', 'Footer')], + 'type', + required=True), + 'text': fields.text('text', translate=True, required=True)} - _columns = {'name' : fields.char('Condition', required=True, size=128), - 'type' : fields.selection([('header','Header'), - ('footer','Footer')], - 'type', - required=True), - 'text': fields.text('text', translate=True,required=True)} - - - def get_value(self, cursor,uid, cond_id, field_name, partner_id=False): - if not cond_id : + def get_value(self, cursor, uid, cond_id, field_name, partner_id=False): + if not cond_id: return {} part_obj = self.pool.get('res.partner') - text ='' - try : + text = '' + try: lang = part_obj.browse(cursor, uid, partner_id).lang - except : + except: lang = 'en_US' cond = self.browse(cursor, uid, cond_id, {'lang': lang}) text = cond.text diff --git a/sale_condition_text/sale_order.py b/sale_condition_text/sale_order.py index ba02b868f69..796ffd1e614 100644 --- a/sale_condition_text/sale_order.py +++ b/sale_condition_text/sale_order.py @@ -1,44 +1,52 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright Camptocamp SA # -############################################################################## +# from osv import osv, fields class SaleOrder(osv.osv): + """Add text condition""" _inherit = "sale.order" - _columns = {'text_condition1': fields.many2one('account.condition_text', 'Header'), - 'text_condition2': fields.many2one('account.condition_text', 'Footer'), - 'note1': fields.text('Header'), - 'note2': fields.text('Footer')} + _columns = { + 'text_condition1': fields.many2one('account.condition_text', 'Header'), + 'text_condition2': fields.many2one('account.condition_text', 'Footer'), + 'note1': fields.text('Header'), + 'note2': fields.text('Footer')} - def set_condition(self, cursor, uid, inv_id, cond_id, field_name, partner_id): + def set_condition( + self, cursor, uid, inv_id, cond_id, field_name, partner_id + ): cond_obj = self.pool.get('account.condition_text') return cond_obj.get_value(cursor, uid, cond_id, field_name, partner_id) - def action_invoice_create(self, cursor, user, order_id, grouped=False, - states=['confirmed', 'done', 'exception'], date_inv = False, context = None): - #function is design to return only one id + def action_invoice_create( + self, cursor, user, order_id, grouped=False, + states=['confirmed', 'done', 'exception'], date_inv=False, context=None + ): + # function is design to return only one id invoice_obj = self.pool.get('account.invoice') - inv_id = super(SaleOrder, self).action_invoice_create(cursor, user, order_id, grouped, states, date_inv, context) + inv_id = super(SaleOrder, self).action_invoice_create( + cursor, user, order_id, grouped, states, date_inv, context) invoice = invoice_obj.browse(cursor, user, inv_id) if isinstance(order_id, list): if len(order_id) > 1: - raise osv.except_osv(_('action_invoice_create can only receive one id'), - _('action_invoice_create can only receive one id')) - - order_id = order_id[0] + raise osv.except_osv( + _('action_invoice_create can only receive one id'), + _('action_invoice_create can only receive one id')) + + order_id = order_id[0] order = self.browse(cursor, user, order_id) inv_data = {'text_condition1': order.text_condition1.id, 'text_condition2': order.text_condition2.id, 'note1': order.note1, 'note2': order.note2} - invoice.write(inv_data, context = context) + invoice.write(inv_data, context=context) return inv_id SaleOrder() diff --git a/sale_delivery_term/__init__.py b/sale_delivery_term/__init__.py index 94421e2af54..cd53b75be02 100644 --- a/sale_delivery_term/__init__.py +++ b/sale_delivery_term/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# +# +# # Copyright (C) 2012 Agile Business Group sagl () # Copyright (C) 2012 Domsense srl () # @@ -17,5 +17,5 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import sale diff --git a/sale_delivery_term/__openerp__.py b/sale_delivery_term/__openerp__.py index ee6c6a73c41..be22739bf2e 100644 --- a/sale_delivery_term/__openerp__.py +++ b/sale_delivery_term/__openerp__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# +# +# # Copyright (C) 2012 Agile Business Group sagl () # Copyright (C) 2012 Domsense srl () # @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# { 'name': "Sale delivery terms", 'version': '0.1', @@ -25,22 +25,25 @@ 'summary': "Delivery term for sale orders", 'description': """ Delivery term for sale orders. -You can configure delivery terms specifying the quantity percentage and the delay for every term line. -You can then associate the term to the 'main' order line and generate the 'detailed' order lines which in turn will generate several pickings according to delivery term (thanks to 'sale_multi_picking' module). +You can configure delivery terms specifying the quantity percentage and the +delay for every term line. +You can then associate the term to the 'main' order line and generate +the 'detailed' order lines which in turn will generate several pickings +according to delivery term (thanks to 'sale_multi_picking' module). """, 'author': 'Agile Business Group', 'website': 'http://www.agilebg.com', 'license': 'AGPL-3', - "depends" : ['sale_multi_picking'], - "data" : [ + "depends": ['sale_multi_picking'], + "data": [ 'sale_view.xml', 'security/ir.model.access.csv', 'sale_data.xml', - ], + ], 'test': [ 'test/sale_order_demo.yml', - ], - "demo" : ['sale_demo.xml'], + ], + "demo": ['sale_demo.xml'], "active": False, "installable": True } diff --git a/sale_delivery_term/sale.py b/sale_delivery_term/sale.py index 280787cdd1f..18a8b165485 100644 --- a/sale_delivery_term/sale.py +++ b/sale_delivery_term/sale.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# +# +# # Copyright (C) 2012 Agile Business Group sagl () # Copyright (C) 2012 Domsense srl () # @@ -17,82 +17,108 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import fields, orm from openerp.tools.translate import _ import openerp.addons.decimal_precision as dp + class sale_delivery_term(orm.Model): _name = 'sale.delivery.term' _columns = { 'name': fields.char('Name', size=64, required=True), - 'line_ids': fields.one2many('sale.delivery.term.line', 'term_id', 'Lines', required=True), - 'company_id': fields.many2one('res.company','Company',required=True,select=1), - } + 'line_ids': fields.one2many( + 'sale.delivery.term.line', 'term_id', 'Lines', required=True), + 'company_id': fields.many2one( + 'res.company', 'Company', required=True, select=1), + } _defaults = { - 'company_id': lambda self,cr,uid,c: self.pool.get( - 'res.company')._company_default_get(cr, uid, 'sale.delivery.term', context=c), + 'company_id': lambda self, cr, uid, c: self.pool.get( + 'res.company')._company_default_get( + cr, uid, 'sale.delivery.term', context=c), } - + def is_total_percentage_correct(self, cr, uid, term_ids, context=None): for term in self.browse(cr, uid, term_ids, context=context): total = 0.0 for line in term.line_ids: total += line.quantity_perc - if total != 1 : + if total != 1: return False return True + class sale_delivery_term_line(orm.Model): _name = 'sale.delivery.term.line' _rec_name = 'term_id' _columns = { - 'term_id': fields.many2one('sale.delivery.term', 'Term', ondelete='cascade'), - 'quantity_perc': fields.float('Quantity percentage', required=True, - help="For 20% set '0.2'", digits_compute=dp.get_precision('Sale Delivery Term')), - 'delay': fields.float('Delivery Lead Time', required=True, - help="Number of days between the order confirmation and the shipping of the products to the customer"), - } + 'term_id': fields.many2one( + 'sale.delivery.term', 'Term', ondelete='cascade'), + 'quantity_perc': fields.float( + 'Quantity percentage', required=True, + help="For 20% set '0.2'", + digits_compute=dp.get_precision('Sale Delivery Term')), + 'delay': fields.float( + 'Delivery Lead Time', required=True, + help="Number of days between the order confirmation and the " + "shipping of the products to the customer"), + } + class sale_order_line_master(orm.Model): - + def _clean_on_change_dict(self, res_dict): - if res_dict['value'].has_key('delay'): + if 'delay' in res_dict['value']: del res_dict['value']['delay'] - if res_dict['value'].has_key('th_weight'): + if 'th_weight' in res_dict['value']: del res_dict['value']['th_weight'] - if res_dict['value'].has_key('type'): + if 'type' in res_dict['value']: del res_dict['value']['type'] - if res_dict['value'].has_key('tax_id'): + if 'tax_id' in res_dict['value']: res_dict['value']['tax_ids'] = res_dict['value']['tax_id'] del res_dict['value']['tax_id'] return res_dict - - def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, + + def product_id_change( + self, cr, uid, ids, pricelist, product, qty=0, uom=False, qty_uos=0, uos=False, name='', partner_id=False, lang=False, update_tax=True, date_order=False, packaging=False, - fiscal_position=False, flag=False, context=None): - res = self.pool.get('sale.order.line').product_id_change(cr, uid, ids, pricelist, product, qty=qty, - uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id, - lang=lang, update_tax=update_tax, date_order=date_order, - packaging=packaging, fiscal_position=fiscal_position, flag=flag, context=context) + fiscal_position=False, flag=False, context=None + ): + res = self.pool.get( + 'sale.order.line').product_id_change( + cr, uid, ids, pricelist, product, qty=qty, + uom=uom, qty_uos=qty_uos, uos=uos, name=name, + partner_id=partner_id, + lang=lang, update_tax=update_tax, date_order=date_order, + packaging=packaging, fiscal_position=fiscal_position, + flag=flag, context=context) return self._clean_on_change_dict(res) - - def product_uom_change(self, cursor, user, ids, pricelist, product, qty=0, - uom=False, qty_uos=0, uos=False, name='', partner_id=False, - lang=False, update_tax=True, date_order=False, context=None): - res = self.pool.get('sale.order.line').product_uom_change(cursor, user, ids, pricelist, product, qty=qty, - uom=uom, qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id, - lang=lang, update_tax=update_tax, date_order=date_order, context=context) + + def product_uom_change( + self, cursor, user, ids, pricelist, product, qty=0, + uom=False, qty_uos=0, uos=False, name='', partner_id=False, + lang=False, update_tax=True, date_order=False, context=None + ): + res = self.pool.get( + 'sale.order.line').product_uom_change( + cursor, user, ids, pricelist, product, qty=qty, + uom=uom, qty_uos=qty_uos, uos=uos, name=name, + partner_id=partner_id, + lang=lang, update_tax=update_tax, date_order=date_order, + context=context) return self._clean_on_change_dict(res) - - def product_packaging_change(self, cr, uid, ids, pricelist, product, qty=0, uom=False, - partner_id=False, packaging=False, flag=False, context=None): + + def product_packaging_change( + self, cr, uid, ids, pricelist, product, qty=0, uom=False, + partner_id=False, packaging=False, flag=False, context=None + ): return self.pool.get('sale.order.line').product_packaging_change( cr, uid, ids, pricelist, product, qty=qty, uom=uom, - partner_id=partner_id, packaging=packaging, flag=flag, context=context) + partner_id=partner_id, packaging=packaging, flag=flag, + context=context) def _amount_line(self, cr, uid, ids, field_name, arg, context=None): tax_obj = self.pool.get('account.tax') @@ -102,56 +128,78 @@ def _amount_line(self, cr, uid, ids, field_name, arg, context=None): context = {} for line in self.browse(cr, uid, ids, context=context): price = line.price_unit * (1 - (line.discount or 0.0) / 100.0) - taxes = tax_obj.compute_all(cr, uid, line.tax_ids, price, + taxes = tax_obj.compute_all( + cr, uid, line.tax_ids, price, line.product_uom_qty, line.order_id.partner_invoice_id.id, line.product_id, line.order_id.partner_id) cur = line.order_id.pricelist_id.currency_id res[line.id] = cur_obj.round(cr, uid, cur, taxes['total']) return res - + def _get_uom_id(self, cr, uid, *args): return self.pool.get('sale.order.line')._get_uom_id(cr, uid, args) - + _name = 'sale.order.line.master' _columns = { - 'order_id': fields.many2one('sale.order', 'Order Reference', required=True, ondelete='cascade'), - 'delivery_term_id': fields.many2one('sale.delivery.term', 'Delivery term', + 'order_id': fields.many2one( + 'sale.order', 'Order Reference', required=True, + ondelete='cascade'), + 'delivery_term_id': fields.many2one( + 'sale.delivery.term', 'Delivery term', required=True, ondelete='restrict'), 'name': fields.char('Description', size=256, required=True), - 'product_id': fields.many2one('product.product', 'Product', domain=[('sale_ok', '=', True)]), - 'price_unit': fields.float('Unit Price', required=True, digits_compute= dp.get_precision('Product Price')), + 'product_id': fields.many2one( + 'product.product', 'Product', + domain=[('sale_ok', '=', True)]), + 'price_unit': fields.float( + 'Unit Price', required=True, + digits_compute=dp.get_precision('Product Price')), 'price_subtotal': fields.function(_amount_line, string='Subtotal', - digits_compute= dp.get_precision('Product Price')), - 'product_uom_qty': fields.float('Quantity (UoM)', digits_compute= dp.get_precision('Product UoS'), required=True), - 'product_uom': fields.many2one('product.uom', 'Unit of Measure ', required=True), - 'product_uos_qty': fields.float('Quantity (UoS)' ,digits_compute= dp.get_precision('Product UoS')), + digits_compute=dp.get_precision( + 'Product Price')), + 'product_uom_qty': fields.float( + 'Quantity (UoM)', digits_compute=dp.get_precision('Product UoS'), + required=True), + 'product_uom': fields.many2one( + 'product.uom', 'Unit of Measure ', required=True), + 'product_uos_qty': fields.float( + 'Quantity (UoS)', digits_compute=dp.get_precision('Product UoS')), 'product_uos': fields.many2one('product.uom', 'Product UoS'), 'product_packaging': fields.many2one('product.packaging', 'Packaging'), - 'order_line_ids': fields.one2many('sale.order.line', 'master_line_id', 'Detailed lines'), + 'order_line_ids': fields.one2many( + 'sale.order.line', 'master_line_id', 'Detailed lines'), 'discount': fields.float('Discount (%)', digits=(16, 2)), - 'tax_ids': fields.many2many('account.tax', 'sale_master_order_line_tax', 'order_line_id', 'tax_id', 'Taxes'), - } + 'tax_ids': fields.many2many( + 'account.tax', 'sale_master_order_line_tax', 'order_line_id', + 'tax_id', 'Taxes'), + } _defaults = { - 'product_uom' : _get_uom_id, + 'product_uom': _get_uom_id, 'product_uom_qty': 1, 'product_uos_qty': 1, 'product_packaging': False, 'price_unit': 0.0, } - - def _prepare_order_line(self, cr, uid, term_line, master_line, group_index=0, context=None): + + def _prepare_order_line( + self, cr, uid, term_line, master_line, group_index=0, context=None + ): order_line_pool = self.pool.get('sale.order.line') group_pool = self.pool.get('sale.order.line.group') group_ids = group_pool.search(cr, uid, []) product_uom_qty = master_line.product_uom_qty * term_line.quantity_perc product_uos_qty = master_line.product_uos_qty * term_line.quantity_perc order_line_vals = {} - on_change_res = order_line_pool.product_id_change(cr, uid, [], master_line.order_id.pricelist_id.id, + on_change_res = order_line_pool.product_id_change( + cr, uid, [], master_line.order_id.pricelist_id.id, master_line.product_id.id, qty=product_uom_qty, uom=master_line.product_uom.id, qty_uos=product_uos_qty, - uos=master_line.product_uos.id, name=master_line.name, partner_id=master_line.order_id.partner_id.id, - lang=False, update_tax=True, date_order=master_line.order_id.date_order, - packaging=master_line.product_packaging.id, fiscal_position=master_line.order_id.fiscal_position.id, + uos=master_line.product_uos.id, name=master_line.name, + partner_id=master_line.order_id.partner_id.id, + lang=False, update_tax=True, + date_order=master_line.order_id.date_order, + packaging=master_line.product_packaging.id, + fiscal_position=master_line.order_id.fiscal_position.id, flag=False, context=context) order_line_vals.update(on_change_res['value']) order_line_vals.update({ @@ -160,47 +208,61 @@ def _prepare_order_line(self, cr, uid, term_line, master_line, group_index=0, co 'price_unit': master_line.price_unit, 'product_uom_qty': product_uom_qty, 'product_uom': master_line.product_uom.id, - 'product_id': master_line.product_id and master_line.product_id.id or False, + 'product_id': ( + master_line.product_id and master_line.product_id.id or False), 'product_uos_qty': product_uos_qty, - 'product_uos': master_line.product_uos and master_line.product_uos.id or False, + 'product_uos': ( + master_line.product_uos and master_line.product_uos.id + or False), 'product_packaging': master_line.product_packaging.id, 'master_line_id': master_line.id, 'delay': term_line.delay, 'picking_group_id': group_ids[group_index], - 'tax_id': [(6,0, [tax.id for tax in master_line.tax_ids])], - }) + 'tax_id': [(6, 0, [tax.id for tax in master_line.tax_ids])], + }) return order_line_vals - - + def generate_detailed_lines(self, cr, uid, ids, context=None): group_pool = self.pool.get('sale.order.line.group') order_line_pool = self.pool.get('sale.order.line') group_ids = group_pool.search(cr, uid, []) for master_line in self.browse(cr, uid, ids): if master_line.order_line_ids: - raise orm.except_orm(_('Error'), - _("Detailed lines generated yet (for master line '%s'). Remove them first") % master_line.name) + raise orm.except_orm( + _('Error'), + _("Detailed lines generated yet (for master line '%s'). " + "Remove them first") % master_line.name) if len(master_line.delivery_term_id.line_ids) > len(group_ids): - raise orm.except_orm(_('Error'), - _("Delivery term lines are %d. Order line groups are %d. Please create more groups") - % (len(master_line.delivery_term_id.line_ids), len(group_ids))) + raise orm.except_orm( + _('Error'), + _("Delivery term lines are %d. Order line groups are %d. " + "Please create more groups") + % (len(master_line.delivery_term_id.line_ids), + len(group_ids))) if not master_line.delivery_term_id.is_total_percentage_correct(): - raise orm.except_orm(_('Error'), - _("Total percentage of delivery term %s is not equal to 1") % master_line.delivery_term_id.name) - for group_index, term_line in enumerate(master_line.delivery_term_id.line_ids): + raise orm.except_orm( + _('Error'), + _("Total percentage of delivery term %s is not equal to 1") + % master_line.delivery_term_id.name) + for group_index, term_line in enumerate( + master_line.delivery_term_id.line_ids + ): order_line_vals = self._prepare_order_line( - cr, uid, term_line, master_line, group_index=group_index, context=context) - order_line_pool.create(cr, uid, order_line_vals, context=context) + cr, uid, term_line, master_line, group_index=group_index, + context=context) + order_line_pool.create( + cr, uid, order_line_vals, context=context) return True - + def copy_data(self, cr, uid, id, default=None, context=None): if not default: default = {} default.update({ 'order_line_ids': [], - }) - return super(sale_order_line_master, self).copy_data(cr, uid, id, default, context=context) - + }) + return super(sale_order_line_master, self).copy_data( + cr, uid, id, default, context=context) + def check_master_line_total(self, cr, uid, ids, context=None): for master_line in self.browse(cr, uid, ids, context): master_uom_qty = master_line.product_uom_qty @@ -211,45 +273,58 @@ def check_master_line_total(self, cr, uid, ids, context=None): total_uom_qty += order_line.product_uom_qty total_uos_qty += order_line.product_uos_qty if master_uom_qty != total_uom_qty: - raise orm.except_orm(_('Error'), _('Order lines total quantity %s is different from master line quantity %s') % (total_uom_qty, master_uom_qty)) + raise orm.except_orm( + _('Error'), + _('Order lines total quantity %s is different from master ' + 'line quantity %s') % (total_uom_qty, master_uom_qty)) if master_uos_qty != total_uos_qty: - raise orm.except_orm(_('Error'), _('Order lines total quantity %s is different from master line quantity %s') % (total_uos_qty, master_uos_qty)) + raise orm.except_orm( + _('Error'), + _('Order lines total quantity %s is different from master ' + 'line quantity %s') % (total_uos_qty, master_uos_qty)) + class sale_order_line(orm.Model): _inherit = 'sale.order.line' _columns = { - 'master_line_id': fields.many2one('sale.order.line.master', 'Master Line'), - } - + 'master_line_id': fields.many2one( + 'sale.order.line.master', 'Master Line'), + } + def copy_data(self, cr, uid, id, default=None, context=None): if not default: default = {} default.update({'master_line_id': False}) - return super(sale_order_line, self).copy_data(cr, uid, id, default, context=context) + return super(sale_order_line, self).copy_data( + cr, uid, id, default, context=context) class sale_order(orm.Model): _inherit = 'sale.order' _columns = { - 'master_order_line': fields.one2many('sale.order.line.master', 'order_id', 'Master Order Lines', readonly=True, states={'draft': [('readonly', False)]}), - } - + 'master_order_line': fields.one2many( + 'sale.order.line.master', 'order_id', 'Master Order Lines', + readonly=True, states={'draft': [('readonly', False)]}), + } + def copy(self, cr, uid, id, default=None, context=None): if not default: default = {} default.update({ 'order_line': [], }) - return super(sale_order, self).copy(cr, uid, id, default, context=context) - + return super(sale_order, self).copy( + cr, uid, id, default, context=context) + def generate_detailed_lines(self, cr, uid, ids, context=None): for order in self.browse(cr, uid, ids, context): for master_line in order.master_order_line: master_line.generate_detailed_lines() return True - + def action_wait(self, cr, uid, ids, context=None): for order in self.browse(cr, uid, ids, context): for master_line in order.master_order_line: master_line.check_master_line_total() - return super(sale_order,self).action_wait(cr, uid, ids, context=context) + return super(sale_order, self).action_wait( + cr, uid, ids, context=context) diff --git a/sale_dropshipping/__init__.py b/sale_dropshipping/__init__.py index 45bbe38f0b1..77d5128ecac 100755 --- a/sale_dropshipping/__init__.py +++ b/sale_dropshipping/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # OpenERP, Open Source Management Solution # Copyright (C) 20010 Akretion LDTA (). @@ -18,7 +18,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import purchase from . import sale diff --git a/sale_dropshipping/__openerp__.py b/sale_dropshipping/__openerp__.py index 5bedb97aa13..1c1838e0370 100755 --- a/sale_dropshipping/__openerp__.py +++ b/sale_dropshipping/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # OpenERP, Open Source Management Solution # Copyright (C) 20010 Akretion LDTA (). @@ -18,7 +18,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# {"name": "Sale Dropshipping", "version": "1.1.1", "author": "Akretion", @@ -27,12 +27,14 @@ "depends": ["purchase", "sale_stock"], "description": """ -Makes it better to deal with purchases with known sale schemes, specially the following case: +Makes it better to deal with purchases with known sale schemes, specially the +following case: 1) normal 2) direct delivery (also called drop shipping) 3) direct invoice 4) direct delivery and direct invoice -See the attached diagram in images/purchase_to_sale.png to see the difference between those flows. +See the attached diagram in images/purchase_to_sale.png to see the difference +between those flows. In all those specific MTO (by opposition of MTS) cases, it will link the sale order line and the purchase order lines together. @@ -46,9 +48,11 @@ line has more products than the virtual quantity available, then it selects drop shipping by default. -In the out going product list view, you can filter in or out drop shipping picking. +In the out going product list view, you can filter in or out drop shipping +picking. -TODO: eventually it might be interesting to do a chained move from supplier to internal location and +TODO: eventually it might be interesting to do a chained move from supplier to +internal location and from internal location to customer instead of supplier o customer directly. This would enable moves to properly generate accounting moves in the stock journal for better tracking. @@ -57,7 +61,11 @@ "demo_xml": [], "test": ['test/test_sale_policy_procurement.yml', ], - "update_xml": ["purchase_view.xml", "sale_view.xml", "product_view.xml", "stock_view.xml"], + "update_xml": [ + "purchase_view.xml", + "sale_view.xml", + "product_view.xml", + "stock_view.xml"], 'images': ['images/purchase_to_sale.png'], 'installable': True, 'certificate': None, diff --git a/sale_dropshipping/product.py b/sale_dropshipping/product.py index b37e3e3bc38..b98cc02a921 100644 --- a/sale_dropshipping/product.py +++ b/sale_dropshipping/product.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # OpenERP, Open Source Management Solution # Copyright (C) 2011 Akretion LDTA (). @@ -18,7 +18,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import fields, orm @@ -37,15 +37,19 @@ class product_product(orm.Model): _inherit = "product.product" - def _is_direct_delivery_from_product(self, cr, uid, ids, name, arg, context=None): + def _is_direct_delivery_from_product( + self, cr, uid, ids, name, arg, context=None + ): res = {} def is_direct_delivery_from_suppliers(product): - cr.execute("""SELECT direct_delivery_flag FROM product_supplierinfo - INNER JOIN res_partner ON product_supplierinfo.name = res_partner.id - WHERE product_id=%s - AND active=true ORDER BY sequence ASC LIMIT 1;""", - (product.product_tmpl_id.id,)) + cr.execute( + """SELECT direct_delivery_flag FROM product_supplierinfo + INNER JOIN res_partner + ON product_supplierinfo.name = res_partner.id + WHERE product_id=%s + AND active=true ORDER BY sequence ASC LIMIT 1;""", + (product.product_tmpl_id.id,)) result = cr.fetchone() if result and result[0]: return True @@ -57,15 +61,18 @@ def is_direct_delivery_from_suppliers(product): elif 'qty' in context: # TODO deal with partial availability? if product.virtual_available < context['qty']: - res[product.id] = is_direct_delivery_from_suppliers(product) + res[product.id] = is_direct_delivery_from_suppliers( + product) else: # Available in stock res[product.id] = False else: # No quantity mentioned so we answer for 'any' quantity res[product.id] = is_direct_delivery_from_suppliers(product) return res - _columns = {'is_direct_delivery_from_product': fields.function(_is_direct_delivery_from_product, - method=True, - type='boolean', - string="Is Supplier Direct Delivery Automatic?") + _columns = { + 'is_direct_delivery_from_product': fields.function( + _is_direct_delivery_from_product, + method=True, + type='boolean', + string="Is Supplier Direct Delivery Automatic?") } diff --git a/sale_dropshipping/purchase.py b/sale_dropshipping/purchase.py index 1212efc8884..b900dcbe710 100644 --- a/sale_dropshipping/purchase.py +++ b/sale_dropshipping/purchase.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # OpenERP, Open Source Management Solution # Copyright (C) 2010 Akretion LDTA (). @@ -18,7 +18,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import fields, orm @@ -26,7 +26,8 @@ class purchase_order_line(orm.Model): _inherit = "purchase.order.line" _columns = { - 'sale_order_line_id': fields.many2one('sale.order.line', 'Sale Order Line'), + 'sale_order_line_id': fields.many2one( + 'sale.order.line', 'Sale Order Line'), } @@ -34,15 +35,17 @@ class purchase_order(orm.Model): _inherit = "purchase.order" _columns = { - 'analytic_account_id': fields.many2one('account.analytic.account', 'Analytic Account'), + 'analytic_account_id': fields.many2one( + 'account.analytic.account', 'Analytic Account'), 'sale_id': fields.many2one('sale.order', 'Related Sale Order'), - 'sale_flow': fields.selection([('normal', 'Normal'), - ('direct_delivery', 'Drop Shipping'), - ('direct_invoice', 'Direct Invoice/Indirect Delivery'), - ('direct_invoice_and_delivery', 'Direct Invoice')], - 'Sale Flow', - help="Is this order tied to a sale order?" - " How will it be delivered and invoiced then?"), + 'sale_flow': fields.selection([ + ('normal', 'Normal'), + ('direct_delivery', 'Drop Shipping'), + ('direct_invoice', 'Direct Invoice/Indirect Delivery'), + ('direct_invoice_and_delivery', 'Direct Invoice')], + 'Sale Flow', + help="Is this order tied to a sale order?" + " How will it be delivered and invoiced then?"), } _defaults = { @@ -82,13 +85,18 @@ def sale_flow_change(self, cr, uid, ids, sale_flow, sale_id, return {} def action_picking_create(self, cr, uid, ids, context=None): - res = super(purchase_order, self).action_picking_create(cr, uid, ids, context=context) + res = super(purchase_order, self).action_picking_create( + cr, uid, ids, context=context) picking_obj = self.pool.get('stock.picking') for purchase in self.browse(cr, uid, ids, context=context): - # TODO bad code inherited from OpenERP, see bug https://bugs.launchpad.net/openobject-addons/+bug/788789 + # TODO bad code inherited from OpenERP, see bug + # https://bugs.launchpad.net/openobject-addons/+bug/788789 if res: if purchase.sale_flow == 'direct_delivery': - if purchase.sale_id and purchase.sale_id.order_policy == 'picking': + if ( + purchase.sale_id + and purchase.sale_id.order_policy == 'picking') + : invoice_control = '2binvoiced' else: invoice_control = 'none' diff --git a/sale_dropshipping/sale.py b/sale_dropshipping/sale.py index 1da0cb155d8..0c17c6d7d59 100644 --- a/sale_dropshipping/sale.py +++ b/sale_dropshipping/sale.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # OpenERP, Open Source Management Solution # Copyright (C) 2011 Akretion LDTA (). @@ -18,7 +18,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm, fields from openerp.tools.translate import _ import netsvc @@ -28,61 +28,76 @@ class sale_order_line(orm.Model): _inherit = "sale.order.line" def product_id_change(self, cr, uid, ids, pricelist, product, qty=0, - uom=False, qty_uos=0, uos=False, name='', partner_id=False, - lang=False, update_tax=True, date_order=False, packaging=False, + uom=False, qty_uos=0, uos=False, name='', + partner_id=False, + lang=False, update_tax=True, date_order=False, + packaging=False, fiscal_position=False, flag=False, context=None): - result = super(sale_order_line, self).product_id_change(cr, uid, ids, pricelist, - product, qty, - uom, qty_uos, uos, name, partner_id, lang, - update_tax, date_order, packaging, - fiscal_position, flag, context) + result = super( + sale_order_line, self).product_id_change( + cr, uid, ids, pricelist, + product, qty, + uom, qty_uos, uos, name, partner_id, lang, + update_tax, date_order, packaging, + fiscal_position, flag, context) if product: context2 = {'lang': lang, 'partner_id': partner_id, 'qty': qty, } - product_obj = self.pool.get('product.product').browse(cr, uid, product, - context=context2) + product_obj = self.pool.get( + 'product.product').browse(cr, uid, product, + context=context2) if product_obj.is_direct_delivery_from_product: result['value'].update({'type': 'make_to_order', 'sale_flow': 'direct_delivery'}) return result - def _purchase_order_line_id(self, cr, uid, ids, field_name, arg, context=None): + def _purchase_order_line_id( + self, cr, uid, ids, field_name, arg, context=None + ): result = {} po_line_class = self.pool.get('purchase.order.line') for order_line in self.browse(cr, uid, ids, context=context): - po_line_ids = po_line_class.search(cr, uid, - [('sale_order_line_id', '=', order_line.id), - ('order_id.state', '!=', 'cancel')]) + po_line_ids = po_line_class.search( + cr, uid, + [ + ('sale_order_line_id', '=', order_line.id), + ('order_id.state', '!=', 'cancel') + ]) result[order_line.id] = po_line_ids and po_line_ids[0] or False return result _columns = { - 'sale_flow': fields.selection([('normal', 'Normal'), - ('direct_delivery', 'Drop Shipping'), - ('direct_invoice', 'Direct Invoice/Indirect Delivery'), - ('direct_invoice_and_delivery', 'Direct Invoice')], - 'Sale Flow', - help="Is this order tied to a sale order?" - " How will it be delivered and invoiced then?"), - - 'purchase_order_line_id': fields.function(_purchase_order_line_id, - type='many2one', - relation='purchase.order.line', - string='Purchase Order Line'), - - 'purchase_order_id': fields.related('purchase_order_line_id', 'order_id', - type='many2one', - relation='purchase.order', - string='Purchase Order'), - - 'purchase_order_state': fields.related('purchase_order_id', 'state', - type='char', - size=64, - string='Purchase Order State'), + 'sale_flow': fields.selection([ + ('normal', 'Normal'), + ('direct_delivery', 'Drop Shipping'), + ('direct_invoice', 'Direct Invoice/Indirect Delivery'), + ('direct_invoice_and_delivery', 'Direct Invoice')], + 'Sale Flow', + help="Is this order tied to a sale order?" + " How will it be delivered and invoiced then?"), + + 'purchase_order_line_id': fields.function( + _purchase_order_line_id, + type='many2one', + relation='purchase.order.line', + string='Purchase Order Line'), + + 'purchase_order_id': fields.related( + 'purchase_order_line_id', + 'order_id', + type='many2one', + relation='purchase.order', + string='Purchase Order'), + + 'purchase_order_state': fields.related( + 'purchase_order_id', 'state', + type='char', + size=64, + string='Purchase Order State'), } _defaults = { @@ -97,11 +112,15 @@ class sale_order(orm.Model): def _prepare_order_line_procurement(self, cr, uid, order, line, move_id, date_planned, context=None): - res = super(sale_order, self)._prepare_order_line_procurement(cr, uid, order, line, - move_id, date_planned, - context) + res = super( + sale_order, self)._prepare_order_line_procurement( + cr, uid, order, line, + move_id, date_planned, + context) res['sale_order_line_id'] = line.id - if line.sale_flow in ['direct_delivery', 'direct_invoice_and_delivery']: + if line.sale_flow in [ + 'direct_delivery', 'direct_invoice_and_delivery' + ]: res['location_id'] = order.partner_id.property_stock_supplier.id return res @@ -160,13 +179,17 @@ class procurement_order(orm.Model): _inherit = 'procurement.order' _columns = { - 'sale_order_line_id': fields.many2one('sale.order.line', 'Sale Order Line'), + 'sale_order_line_id': fields.many2one( + 'sale.order.line', 'Sale Order Line'), } - def create_procurement_purchase_order(self, cr, uid, procurement, po_vals, line_vals, - context=None): + def create_procurement_purchase_order( + self, cr, uid, procurement, po_vals, line_vals, + context=None + ): if procurement.sale_order_line_id: - warehouse_id = procurement.sale_order_line_id.order_id.shop_id.warehouse_id + warehouse_id = ( + procurement.sale_order_line_id.order_id.shop_id.warehouse_id) sale_flow = procurement.sale_order_line_id.sale_flow purchase_obj = self.pool.get('purchase.order') vals = purchase_obj.sale_flow_change( @@ -175,9 +198,15 @@ def create_procurement_purchase_order(self, cr, uid, procurement, po_vals, line_ warehouse_id.id, context=context) po_vals.update(vals.get('value', {})) - po_vals.update({'sale_flow': sale_flow, - 'sale_id': procurement.sale_order_line_id.order_id.id}) - l_id = procurement.sale_order_line_id.id if procurement.sale_order_line_id else False + po_vals.update({ + 'sale_flow': sale_flow, + 'sale_id': procurement.sale_order_line_id.order_id.id}) + l_id = ( + procurement.sale_order_line_id.id + if procurement.sale_order_line_id else False + ) line_vals.update({'sale_order_line_id': l_id}) - return super(procurement_order, self).create_procurement_purchase_order(cr, uid, procurement, - po_vals, line_vals, context) + return super( + procurement_order, self).create_procurement_purchase_order( + cr, uid, procurement, + po_vals, line_vals, context) diff --git a/sale_exception_nostock/__init__.py b/sale_exception_nostock/__init__.py index e278f0e5f51..9cfb02a19b0 100644 --- a/sale_exception_nostock/__init__.py +++ b/sale_exception_nostock/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Nicolas Bessi # Copyright 2013 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import model from . import test diff --git a/sale_exception_nostock/__openerp__.py b/sale_exception_nostock/__openerp__.py index 928e6212625..0698f4a189e 100644 --- a/sale_exception_nostock/__openerp__.py +++ b/sale_exception_nostock/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Nicolas Bessi # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# {'name': 'Sale stock exception', 'version': '0.1', 'author': 'Camptocamp', @@ -29,7 +29,8 @@ Sale stock exception -------------------- -This addon adds two new sales exceptions to be used by the `sale_exception` addon: +This addon adds two new sales exceptions to be used by the `sale_exception` +addon: * The first one ensures that an order line can be delivered on the delivery date if it is in MTS. Validation is done by using the order line location via diff --git a/sale_exception_nostock/model/__init__.py b/sale_exception_nostock/model/__init__.py index 606fd265f7d..18b20235f96 100644 --- a/sale_exception_nostock/model/__init__.py +++ b/sale_exception_nostock/model/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Nicolas Bessi # Copyright 2013 Camptocamp SA @@ -17,5 +17,5 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import sale diff --git a/sale_exception_nostock/model/sale.py b/sale_exception_nostock/model/sale.py index 54f3631db0c..0ef30dd0c01 100644 --- a/sale_exception_nostock/model/sale.py +++ b/sale_exception_nostock/model/sale.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Nicolas Bessi # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# import datetime from openerp.osv import orm from openerp.tools import (DEFAULT_SERVER_DATE_FORMAT, @@ -25,6 +25,7 @@ class sale_order_line(orm.Model): + """Adds two exception functions to be called by the sale_exceptions module. The first one will ensure that an order line can be delivered on the @@ -70,9 +71,11 @@ def can_command_at_delivery_date(self, cr, uid, l_id, context=None): ctx = context.copy() ctx['to_date'] = delivery_date.strftime(DEFAULT_SERVER_DATETIME_FORMAT) ctx['location'] = self._get_line_location(line, context=context) - ctx['compute_child'] = True # Virtual qty is made on all childs of chosen location + ctx['compute_child'] = True + # Virtual qty is made on all childs of chosen location prod_for_virtual_qty = prod_obj.read(cr, uid, line.product_id.id, - ['virtual_available'], context=ctx) + ['virtual_available'], + context=ctx) if prod_for_virtual_qty['virtual_available'] < line.product_uom_qty: return False return True @@ -80,12 +83,16 @@ def can_command_at_delivery_date(self, cr, uid, l_id, context=None): def _get_states(self): return ('waiting', 'confirmed', 'assigned') - def _get_affected_dates(self, cr, location_id, product_id, delivery_date, context=None): + def _get_affected_dates( + self, cr, location_id, product_id, delivery_date, context=None + ): """Determine future dates where virtual stock has to be checked. It will only look for stock move that pass by location_id. - If your stock location have children or you have configured automated stock action - they must pass by the location related to SO line, else the will be ignored + If your stock location have children or you have configured automated + stock action + they must pass by the location related to SO line, else the will be + ignored :param location_id: location id to be checked :param product_id: product id te be checked @@ -105,7 +112,8 @@ def _get_affected_dates(self, cr, location_id, product_id, delivery_date, contex return (row[0] for row in cr.fetchall()) def future_orders_are_affected(self, cr, uid, l_id, context=None): - """Predicate function that is a naive workaround for the lack of stock reservation. + """Predicate function that is a naive workaround for the lack of stock + reservation. This can be a performance killer, you should not use it if you have constantly a lot of running Orders @@ -125,13 +133,17 @@ def future_orders_are_affected(self, cr, uid, l_id, context=None): ctx = context.copy() location_id = self._get_line_location(line, context=context) ctx['location'] = location_id - ctx['compute_child'] = True # Virtual qty is made on all childs of chosen location + ctx['compute_child'] = True + # Virtual qty is made on all childs of chosen location dates = self._get_affected_dates(cr, location_id, line.product_id.id, delivery_date, context=context) for aff_date in dates: ctx['to_date'] = aff_date prod_for_virtual_qty = prod_obj.read(cr, uid, line.product_id.id, - ['virtual_available'], context=ctx) - if prod_for_virtual_qty['virtual_available'] < line.product_uom_qty: + ['virtual_available'], + context=ctx) + if prod_for_virtual_qty[ + 'virtual_available' + ] < line.product_uom_qty: return True return False diff --git a/sale_exception_nostock/test/__init__.py b/sale_exception_nostock/test/__init__.py index 26ca3ebceb7..916aec7529b 100644 --- a/sale_exception_nostock/test/__init__.py +++ b/sale_exception_nostock/test/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Nicolas Bessi # Copyright 2013 Camptocamp SA @@ -17,5 +17,5 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import test_utils diff --git a/sale_exception_nostock/test/test_utils.py b/sale_exception_nostock/test/test_utils.py index aa1a333ed3a..a1ce5abbe81 100644 --- a/sale_exception_nostock/test/test_utils.py +++ b/sale_exception_nostock/test/test_utils.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Nicolas Bessi # Copyright 2013 Camptocamp SA @@ -17,12 +17,12 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# def check_state_and_exceptions(sale_order, state, exc_id): - assert sale_order.state == state, "Incorrect state %s instead of %s" % (sale_order.state, - state) + assert sale_order.state == state, ( + "Incorrect state %s instead of %s" % (sale_order.state, state)) assert exc_id in [x.id for x in sale_order.exceptions_ids],\ "No exception for %s" % sale_order.name diff --git a/sale_exceptions/__init__.py b/sale_exceptions/__init__.py index ba3f3f6b8b1..7f3d8c531e2 100644 --- a/sale_exceptions/__init__.py +++ b/sale_exceptions/__init__.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # OpenERP, Open Source Management Solution # Copyright (C) 2011 Akretion LTDA. # authors: Raphaël Valyi, Renato Lima -# Copyright (C) 2010-2012 Akretion Sébastien BEAU +# Copyright (C) 2010-2012 Akretion Sébastien BEAU +# # Copyright (C) 2012 Camptocamp SA (Guewen Baconnier) # # This program is free software: you can redistribute it and/or modify @@ -20,7 +21,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import sale from . import wizard diff --git a/sale_exceptions/__openerp__.py b/sale_exceptions/__openerp__.py index 19f32de157d..a2f408a1622 100644 --- a/sale_exceptions/__openerp__.py +++ b/sale_exceptions/__openerp__.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # OpenERP, Open Source Management Solution # Copyright (C) 2011 Akretion LTDA. # authors: Raphaël Valyi, Renato Lima -# Copyright (C) 2010-2012 Akretion Sébastien BEAU +# Copyright (C) 2010-2012 Akretion Sébastien BEAU +# # Copyright (C) 2012 Camptocamp SA (Guewen Baconnier) # # This program is free software: you can redistribute it and/or modify @@ -20,17 +21,18 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# {'name': 'Sale Exceptions', 'version': '0.1', 'category': 'Generic Modules/Sale', 'description': """ -This module allows you attach several customizable exceptions to your sale order - in a way that you can filter orders by exceptions type and fix them. +This module allows you attach several customizable exceptions to your +sale order in a way that you can filter orders by exceptions type and fix them. This is especially useful in an order importation scenario such as with -the base_sale_multi_channels module, because it's likely a few orders have errors -when you import them (like product not found in OpenERP, wrong line format etc...) +the base_sale_multi_channels module, because it's likely a few orders have +errors when you import them (like product not found in OpenERP, wrong line +format etc...) """, 'author': 'Akretion', 'website': 'http://www.akretion.com', diff --git a/sale_exceptions/sale.py b/sale_exceptions/sale.py index 88ee1e04750..988d695d3c2 100644 --- a/sale_exceptions/sale.py +++ b/sale_exceptions/sale.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # OpenERP, Open Source Management Solution # Copyright (C) 2011 Akretion LTDA. -# Copyright (C) 2010-2012 Akretion Sébastien BEAU +# Copyright (C) 2010-2012 Akretion Sébastien BEAU +# # Copyright (C) 2012 Camptocamp SA (Guewen Baconnier) # # This program is free software: you can redistribute it and/or modify @@ -19,7 +20,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# import time @@ -44,8 +45,9 @@ class sale_exception(orm.Model): 'active': fields.boolean('Active'), 'code': fields.text( 'Python Code', - help="Python code executed to check if the exception apply or not. " - "The code must apply block = True to apply the exception."), + help="Python code executed to check if the exception apply or " + "not. The code must apply block = True to apply the " + "exception."), 'sale_order_ids': fields.many2many( 'sale.order', 'sale_order_exception_rel', 'exception_id', 'sale_order_id', @@ -58,7 +60,8 @@ class sale_exception(orm.Model): # You can use the following variables : # - self: ORM model of the record which is checked # - order or line: browse_record of the sale order or sale order line -# - object: same as order or line, browse_record of the sale order or sale order line +# - object: same as order or line, browse_record of the sale order or +# sale order line # - pool: ORM model pool (i.e. self.pool) # - time: Python time module # - cr: database cursor @@ -133,8 +136,8 @@ def action_button_confirm(self, cr, uid, ids, context=None): if exception_ids: return self._popup_exceptions(cr, uid, ids[0], context=context) else: - return super(sale_order, self).action_button_confirm(cr, uid, ids, - context=context) + return super(sale_order, self).action_button_confirm( + cr, uid, ids, context=context) def test_exceptions(self, cr, uid, ids, context=None): """ @@ -176,7 +179,9 @@ def detect_exceptions(self, cr, uid, ids, context=None): context=context) return exception_ids - def _exception_rule_eval_context(self, cr, uid, obj_name, obj, context=None): + def _exception_rule_eval_context( + self, cr, uid, obj_name, obj, context=None + ): if context is None: context = {} @@ -233,4 +238,5 @@ def copy(self, cr, uid, id, default=None, context=None): default.update({ 'ignore_exceptions': False, }) - return super(sale_order, self).copy(cr, uid, id, default=default, context=context) + return super(sale_order, self).copy( + cr, uid, id, default=default, context=context) diff --git a/sale_exceptions/wizard/__init__.py b/sale_exceptions/wizard/__init__.py index d435061c617..e479d7ea701 100644 --- a/sale_exceptions/wizard/__init__.py +++ b/sale_exceptions/wizard/__init__.py @@ -1,10 +1,11 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # OpenERP, Open Source Management Solution # Copyright (C) 2011 Akretion LTDA. # authors: Raphaël Valyi, Renato Lima -# Copyright (C) 2010-2012 Akretion Sébastien BEAU +# Copyright (C) 2010-2012 Akretion Sébastien BEAU +# # Copyright (C) 2012 Camptocamp SA (Guewen Baconnier) # # This program is free software: you can redistribute it and/or modify @@ -20,5 +21,5 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import sale_exception_confirm diff --git a/sale_exceptions/wizard/sale_exception_confirm.py b/sale_exceptions/wizard/sale_exception_confirm.py index af7aace61a6..9e0db9f5c3c 100644 --- a/sale_exceptions/wizard/sale_exception_confirm.py +++ b/sale_exceptions/wizard/sale_exception_confirm.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright Camptocamp SA # @author: Guewen Baconnier @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm, fields diff --git a/sale_fiscal_position_update/__init__.py b/sale_fiscal_position_update/__init__.py index e9481e1fa0e..8f883912787 100755 --- a/sale_fiscal_position_update/__init__.py +++ b/sale_fiscal_position_update/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Sale Fiscal Position Update module for OpenERP # Copyright (C) 2011-2014 Julius Network Solutions SARL @@ -18,6 +18,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import sale diff --git a/sale_fiscal_position_update/__openerp__.py b/sale_fiscal_position_update/__openerp__.py index 9405b5fcd6f..529dd12ce94 100755 --- a/sale_fiscal_position_update/__openerp__.py +++ b/sale_fiscal_position_update/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Sale Fiscal Position Update module for OpenERP # Copyright (C) 2011-2014 Julius Network Solutions SARL @@ -18,19 +18,23 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# { 'name': 'Sale Fiscal Position Update', 'version': '1.0', 'category': 'Sales Management', 'license': 'AGPL-3', - 'summary': 'Changing the fiscal position of a sale order will auto-update sale order lines', + 'summary': 'Changing the fiscal position of a sale order will auto-update ' + 'sale order lines', 'description': """ Sale Fiscal Position Update =========================== -With this module, when a user changes the fiscal position of a sale order, the taxes on all the sale order lines which have a product are automatically updated. The sale order lines without a product are not updated and a warning is displayed to the user in this case. +With this module, when a user changes the fiscal position of a sale order, the +taxes on all the sale order lines which have a product are automatically +updated. The sale order lines without a product are not updated and a warning +is displayed to the user in this case. Contributors : diff --git a/sale_fiscal_position_update/sale.py b/sale_fiscal_position_update/sale.py index 5289bd604d3..23ce558aaa2 100644 --- a/sale_fiscal_position_update/sale.py +++ b/sale_fiscal_position_update/sale.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################# +# # # Sale Fiscal Position Update module for OpenERP # Copyright (C) 2011-2014 Julius Network Solutions SARL @@ -20,7 +20,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm from openerp.tools.translate import _ @@ -80,5 +80,5 @@ def fiscal_position_change( "to the new Fiscal Position because they don't have a " "Product:\n %s\nYou should update the " "Taxes of these Sale Order Lines manually." - ) % display_line_names, + ) % display_line_names, return res diff --git a/sale_jit_on_services/__init__.py b/sale_jit_on_services/__init__.py index 9abe6004d91..ec6a644f4ec 100644 --- a/sale_jit_on_services/__init__.py +++ b/sale_jit_on_services/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Yannick Vaucher # Copyright 2014 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import procurement diff --git a/sale_jit_on_services/__openerp__.py b/sale_jit_on_services/__openerp__.py index 8ba4a0c18f8..8b1807547d3 100644 --- a/sale_jit_on_services/__openerp__.py +++ b/sale_jit_on_services/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Joël Grand-Guillaume, Yannick Vaucher # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# { 'name': 'Sale Service Just In Time', diff --git a/sale_jit_on_services/procurement.py b/sale_jit_on_services/procurement.py index 3f10001b466..f7400eaf7ed 100644 --- a/sale_jit_on_services/procurement.py +++ b/sale_jit_on_services/procurement.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Yannick Vaucher # Copyright 2014 Camptocamp SA @@ -17,10 +17,12 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm + class ProcurementOrder(orm.Model): + """ Procurement Orders """ diff --git a/sale_journal_shop/__init__.py b/sale_journal_shop/__init__.py index 62c3c7f552c..9c91a270d8f 100644 --- a/sale_journal_shop/__init__.py +++ b/sale_journal_shop/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################### +# # # Copyright (C) 2013-TODAY Akretion . # @author Sébastien BEAU @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################### +# from . import sale diff --git a/sale_journal_shop/__openerp__.py b/sale_journal_shop/__openerp__.py index 2f8f80eb5bc..738a5dc2cfc 100644 --- a/sale_journal_shop/__openerp__.py +++ b/sale_journal_shop/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################### +# # # Copyright (C) 2014-TODAY Akretion . # @author Sébastien BEAU @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################### +# {'name': 'Sale Journal Shop', 'version': '0.0.1', @@ -38,4 +38,4 @@ ], 'installable': True, 'application': True, -} + } diff --git a/sale_journal_shop/sale.py b/sale_journal_shop/sale.py index 7cad894f5bb..7f9c3bf4e53 100644 --- a/sale_journal_shop/sale.py +++ b/sale_journal_shop/sale.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################### +# # # Copyright (C) 2013-TODAY Akretion . # @author Sébastien BEAU @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################### +# from openerp.osv import fields, orm diff --git a/sale_multi_picking/__init__.py b/sale_multi_picking/__init__.py index 94421e2af54..cd53b75be02 100644 --- a/sale_multi_picking/__init__.py +++ b/sale_multi_picking/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# +# +# # Copyright (C) 2012 Agile Business Group sagl () # Copyright (C) 2012 Domsense srl () # @@ -17,5 +17,5 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import sale diff --git a/sale_multi_picking/__openerp__.py b/sale_multi_picking/__openerp__.py index a4d44c315c9..164254c220e 100644 --- a/sale_multi_picking/__openerp__.py +++ b/sale_multi_picking/__openerp__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# +# +# # Copyright (C) 2012 Agile Business Group sagl () # Copyright (C) 2012 Domsense srl () # @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# { 'name': "Sale multi pickings", 'version': '0.1', @@ -25,19 +25,20 @@ 'summary': "Multi Pickings from Sale Orders", 'description': """ This module allows to generate several pickings from the same sale order. -You just have to indicate which order lines have to be grouped in the same picking. When confirming the order, for each group a picking is generated. +You just have to indicate which order lines have to be grouped in the same +picking. When confirming the order, for each group a picking is generated. """, 'author': 'Agile Business Group', 'website': 'http://www.agilebg.com', 'license': 'AGPL-3', - "depends" : ['sale_stock'], - "data" : [ + "depends": ['sale_stock'], + "data": [ 'sale_view.xml', 'security/ir.model.access.csv', - ], - "demo" : [ + ], + "demo": [ 'sale_demo.xml', - ], + ], "active": False, "installable": True } diff --git a/sale_multi_picking/sale.py b/sale_multi_picking/sale.py index 233c670569d..c316dccae3c 100644 --- a/sale_multi_picking/sale.py +++ b/sale_multi_picking/sale.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# +# +# # Copyright (C) 2012 Agile Business Group sagl () # Copyright (C) 2012 Domsense srl () # @@ -17,28 +17,33 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import fields, orm + class sale_order_line_group(orm.Model): _name = 'sale.order.line.group' _columns = { 'name': fields.char('Group', size=64, required=True), - 'company_id': fields.many2one('res.company','Company',required=True,select=1), - } + 'company_id': fields.many2one( + 'res.company', 'Company', required=True, select=1), + } _defaults = { - 'company_id': lambda self,cr,uid,c: self.pool.get( - 'res.company')._company_default_get(cr, uid, 'sale.order.line.group', context=c), + 'company_id': lambda self, cr, uid, c: self.pool.get( + 'res.company')._company_default_get( + cr, uid, 'sale.order.line.group', context=c), } class sale_order_line(orm.Model): _inherit = 'sale.order.line' _columns = { - 'picking_group_id': fields.many2one('sale.order.line.group', 'Group', - help="This is used by 'multi-picking' to group order lines in one picking"), - } + 'picking_group_id': fields.many2one( + 'sale.order.line.group', 'Group', + help="This is used by 'multi-picking' to group order lines in one " + "picking"), + } class sale_order(orm.Model): @@ -49,15 +54,19 @@ def action_ship_create(self, cr, uid, ids, context=None): for order in self.browse(cr, uid, ids, context=context): lines_by_group = {} for line in order.order_line: - group_id = line.picking_group_id.id if line.picking_group_id else 0 + group_id = ( + line.picking_group_id.id if line.picking_group_id else 0) lines_by_group.setdefault(group_id, []).append(line) for group in lines_by_group: if not group: picking_id = None else: - picking_vals = super(sale_order, self)._prepare_order_picking(cr, uid, order, context=context) - picking_id = picking_pool.create(cr, uid, picking_vals, context=context) + picking_vals = super( + sale_order, self)._prepare_order_picking( + cr, uid, order, context=context) + picking_id = picking_pool.create( + cr, uid, picking_vals, context=context) super(sale_order, self)._create_pickings_and_procurements( - cr, uid, order, lines_by_group[group], picking_id, context=context) + cr, uid, order, lines_by_group[group], picking_id, + context=context) return True - diff --git a/sale_order_force_number/__init__.py b/sale_order_force_number/__init__.py index 6efd821e784..5bf38a5ace2 100644 --- a/sale_order_force_number/__init__.py +++ b/sale_order_force_number/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# +# +# # Copyright (C) 2013 Agile Business Group sagl # () # @@ -17,4 +17,4 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# diff --git a/sale_order_force_number/__openerp__.py b/sale_order_force_number/__openerp__.py index 6290789d5fc..047d45aa5b5 100644 --- a/sale_order_force_number/__openerp__.py +++ b/sale_order_force_number/__openerp__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# +# +# # Copyright (C) 2013 Agile Business Group sagl # () # @@ -17,23 +17,25 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# { 'name': "Sale orders - Force number", 'version': '0.1', 'category': 'Sales Management', 'summary': "Force sale orders numeration", - 'description': """This simple module allows to specify the number to use when creating sale orders. -If user does not change the default value ('/'), the standard sequence is used.""", + 'description': """This simple module allows to specify the number to use +when creating sale orders. +If user does not change the default value ('/'), the standard sequence is used. +""", 'author': 'Agile Business Group', 'website': 'http://www.agilebg.com', 'license': 'AGPL-3', - "depends" : ['purchase'], - "data" : [ + "depends": ['purchase'], + "data": [ 'sale_view.xml', - ], - "demo" : [], + ], + "demo": [], "active": False, "installable": True } diff --git a/sale_quotation_number/__init__.py b/sale_quotation_number/__init__.py index ca86e6eaf7e..1201f4d6cd5 100644 --- a/sale_quotation_number/__init__.py +++ b/sale_quotation_number/__init__.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -############################################################################## -# +# +# # Copyright (c) 2010-2012 Elico Corp. All Rights Reserved. # Author: Andy Lu # Copyright (C) 2013 Agile Business Group sagl () @@ -18,5 +18,5 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# import sale_quotation diff --git a/sale_quotation_number/__openerp__.py b/sale_quotation_number/__openerp__.py index cc21c263e10..59cc96d812a 100644 --- a/sale_quotation_number/__openerp__.py +++ b/sale_quotation_number/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright (c) 2010-2012 Elico Corp. All Rights Reserved. # Author: Andy Lu @@ -19,7 +19,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# { @@ -35,8 +35,8 @@ *Sale Quotation:* Sale process in draft stage just informing prices and element of communication. -*Sale Order:* Sale process confirmed, the customer already have a compromise with -us in terms of pay an invoice and receive our product or service. +*Sale Order:* Sale process confirmed, the customer already have a compromise +with us in terms of pay an invoice and receive our product or service. Originally OpenERP manage only 1 sequence for this 2 documents, then the sales order won and lost manage the same sequence losting almost all lost quotations diff --git a/sale_quotation_number/sale_quotation.py b/sale_quotation_number/sale_quotation.py index 3c89e736d26..c7bd8506856 100644 --- a/sale_quotation_number/sale_quotation.py +++ b/sale_quotation_number/sale_quotation.py @@ -1,4 +1,4 @@ -############################################################################## +# # # OpenERP, Open Source Management Solution # Copyright (C) 2004-2009 Tiny SPRL (). @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import fields, orm diff --git a/sale_sourced_by_line/__init__.py b/sale_sourced_by_line/__init__.py index 643bee7abed..c09d73c4161 100644 --- a/sale_sourced_by_line/__init__.py +++ b/sale_sourced_by_line/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import model diff --git a/sale_sourced_by_line/__openerp__.py b/sale_sourced_by_line/__openerp__.py index 384a15de9d2..2038b55d71b 100644 --- a/sale_sourced_by_line/__openerp__.py +++ b/sale_sourced_by_line/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# {'name': 'Sale Sourced by Line', 'version': '0.1', diff --git a/sale_sourced_by_line/model/__init__.py b/sale_sourced_by_line/model/__init__.py index d65199e72a4..d5d7f376f0f 100644 --- a/sale_sourced_by_line/model/__init__.py +++ b/sale_sourced_by_line/model/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import sale diff --git a/sale_sourced_by_line/model/sale.py b/sale_sourced_by_line/model/sale.py index d49549f7a09..4f75d283445 100644 --- a/sale_sourced_by_line/model/sale.py +++ b/sale_sourced_by_line/model/sale.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Guewen Baconnier # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm, fields diff --git a/sale_stock_global_delivery_lead_time/__init__.py b/sale_stock_global_delivery_lead_time/__init__.py index 9ea5baadf2b..a273eceffc0 100644 --- a/sale_stock_global_delivery_lead_time/__init__.py +++ b/sale_stock_global_delivery_lead_time/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Alexandre Fayolle # Copyright 2013 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import sale_stock diff --git a/sale_stock_global_delivery_lead_time/__openerp__.py b/sale_stock_global_delivery_lead_time/__openerp__.py index 0a2e4d4c981..d6caf13de74 100644 --- a/sale_stock_global_delivery_lead_time/__openerp__.py +++ b/sale_stock_global_delivery_lead_time/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Alexandre Fayolle # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# { 'name': 'Sale global delivery lead time', 'version': '0.1', diff --git a/sale_stock_global_delivery_lead_time/sale_stock.py b/sale_stock_global_delivery_lead_time/sale_stock.py index a01ff812369..c1c7fb7142b 100644 --- a/sale_stock_global_delivery_lead_time/sale_stock.py +++ b/sale_stock_global_delivery_lead_time/sale_stock.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Alexandre Fayolle # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from datetime import datetime from dateutil.relativedelta import relativedelta @@ -28,7 +28,9 @@ class sale_order(orm.Model): _inherit = 'sale.order' - def _min_max_date_planned(self, cr, uid, ids, field_names, arg, context=None): + def _min_max_date_planned( + self, cr, uid, ids, field_names, arg, context=None + ): res = {} if not ids: return res @@ -46,16 +48,19 @@ def _min_max_date_planned(self, cr, uid, ids, field_names, arg, context=None): load='_classic_write') order_line_delays = {} # dict order_id: [line delays] for line_info in line_delays: - order_line_delays.setdefault(line_info['order_id'], []).append(line_info['delay']) + order_line_delays.setdefault( + line_info['order_id'], []).append(line_info['delay']) for sale_info in sale_infos: sale_id = sale_info['id'] res[sale_id] = {} - start_date = datetime.strptime(self.date_to_datetime(cr, uid, - sale_info['date_order'], - context), - DEFAULT_SERVER_DATETIME_FORMAT) - min_delay = sale_info['delay'] + min(order_line_delays.get(sale_id, [0])) - max_delay = sale_info['delay'] + max(order_line_delays.get(sale_id, [0])) + start_date = datetime.strptime( + self.date_to_datetime( + cr, uid, sale_info['date_order'], context), + DEFAULT_SERVER_DATETIME_FORMAT) + min_delay = sale_info['delay'] + min( + order_line_delays.get(sale_id, [0])) + max_delay = sale_info['delay'] + max( + order_line_delays.get(sale_id, [0])) min_date = start_date + relativedelta(days=min_delay) max_date = start_date + relativedelta(days=max_delay) for name in field_names: @@ -65,14 +70,16 @@ def _min_max_date_planned(self, cr, uid, ids, field_names, arg, context=None): date = max_date else: continue - res[sale_id][name] = date.strftime(DEFAULT_SERVER_DATETIME_FORMAT) + res[sale_id][name] = date.strftime( + DEFAULT_SERVER_DATETIME_FORMAT) return res _columns = { 'delay': fields.float('Delivery Lead Time', required=True, help="Number of days between the order " - "confirmation and the shipping of the products " + "confirmation and the shipping of the " + "products " "to the customer. This lead time is added " "to the lead time of each line.", readonly=True, @@ -85,14 +92,17 @@ def _min_max_date_planned(self, cr, uid, ids, field_names, arg, context=None): type='date', string='Latest date planned', method=True, multi='date_planned'), - } + } _defaults = {'delay': 0, } - def _get_date_planned(self, cr, uid, order, line, start_date, context=None): - date_planned = super(sale_order, self)._get_date_planned(cr, uid, order, - line, start_date, - context) + def _get_date_planned( + self, cr, uid, order, line, start_date, context=None + ): + date_planned = super( + sale_order, self)._get_date_planned(cr, uid, order, + line, start_date, + context) date_planned = datetime.strptime(date_planned, DEFAULT_SERVER_DATETIME_FORMAT) date_planned += relativedelta(days=order.delay or 0.0) diff --git a/sale_validity/__init__.py b/sale_validity/__init__.py index 3114393460f..bcdec207558 100644 --- a/sale_validity/__init__.py +++ b/sale_validity/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright 2013 Camptocamp SA # @@ -16,6 +16,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import model diff --git a/sale_validity/__openerp__.py b/sale_validity/__openerp__.py index f606cbeb68e..3273624a3aa 100644 --- a/sale_validity/__openerp__.py +++ b/sale_validity/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Jacques-Etienne Baudoux # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# {"name": "Sales Quotation Validity Date", "version": "7.0.0", @@ -36,9 +36,9 @@ """, 'data': [ - "view/sale_order.xml", - "view/company_view.xml", - ], + "view/sale_order.xml", + "view/company_view.xml", + ], 'installable': True, 'active': False, } diff --git a/sale_validity/model/__init__.py b/sale_validity/model/__init__.py index 56431d18e2b..c5a2a22c141 100644 --- a/sale_validity/model/__init__.py +++ b/sale_validity/model/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright 2013 Camptocamp SA # @@ -16,7 +16,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import company from . import sale_order diff --git a/sale_validity/model/company.py b/sale_validity/model/company.py index 98b9042286a..cd554b0a60c 100644 --- a/sale_validity/model/company.py +++ b/sale_validity/model/company.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright (C) 2014 Akretion (http://www.akretion.com) # @author Alexis de Lattre @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import fields, orm @@ -32,7 +32,7 @@ class res_company(orm.Model): "the date of the sale order plus the number of days defined " "in this field. If the value of this field is 0, the sale orders " "will not have a validity date by default."), - } + } _sql_constraints = [ ('sale_order_validity_days_positive', diff --git a/sale_validity/model/sale_order.py b/sale_validity/model/sale_order.py index b13a8f99f3e..3b29145b678 100644 --- a/sale_validity/model/sale_order.py +++ b/sale_validity/model/sale_order.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Copyright 2013 Camptocamp SA # @@ -16,7 +16,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import fields, orm from openerp.tools import DEFAULT_SERVER_DATE_FORMAT @@ -37,7 +37,7 @@ class sale_order(orm.Model): 'sent': [('readonly', True)], }, track_visibility='onchange'), - } + } def _default_date_validity(self, cr, uid, context=None): date_validity_str = False @@ -57,7 +57,7 @@ def _default_date_validity(self, cr, uid, context=None): _defaults = { 'date_validity': _default_date_validity, - } + } def date_order_change( self, cr, uid, ids, date_order, date_validity, company_id, diff --git a/stock_picking_reorder_lines/__init__.py b/stock_picking_reorder_lines/__init__.py index e9d4bd5b3b5..cc5ed7f7736 100644 --- a/stock_picking_reorder_lines/__init__.py +++ b/stock_picking_reorder_lines/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Alexandre Fayolle # Copyright 2013 Camptocamp SA @@ -17,6 +17,6 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from . import stock diff --git a/stock_picking_reorder_lines/__openerp__.py b/stock_picking_reorder_lines/__openerp__.py index f3360add403..c06c484ba33 100644 --- a/stock_picking_reorder_lines/__openerp__.py +++ b/stock_picking_reorder_lines/__openerp__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Alexandre Fayolle # Copyright 2013 Camptocamp SA @@ -17,13 +17,14 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# { 'name': 'Stock picking lines with sequence number', 'version': '0.1', 'category': 'Warehouse Management', 'description': ''' -Provide a new field on stock moves, allowing to manage the orders of moves in a picking. +Provide a new field on stock moves, allowing to manage the orders of moves +in a picking. ''', 'author': 'Camptocamp', 'website': 'http://www.camptocamp.com', diff --git a/stock_picking_reorder_lines/stock.py b/stock_picking_reorder_lines/stock.py index ba2132f5f8b..e734123e83a 100644 --- a/stock_picking_reorder_lines/stock.py +++ b/stock_picking_reorder_lines/stock.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -############################################################################## +# # # Author: Alexandre Fayolle # Copyright 2013 Camptocamp SA @@ -17,7 +17,7 @@ # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . # -############################################################################## +# from openerp.osv import orm, fields @@ -28,7 +28,7 @@ class stock_move(orm.Model): 'sequence': fields.integer('Sequence', help="Gives the sequence of this line when " "displaying the picking."), - } + } _order = 'date_expected desc, sequence, id' _defaults = {'sequence': 10, } @@ -37,8 +37,10 @@ class stock_move(orm.Model): class stock_picking(orm.Model): _inherit = 'stock.picking' - def _prepare_invoice_line(self, cr, uid, group, picking, move_line, invoice_id, - invoice_vals, context=None): + def _prepare_invoice_line( + self, cr, uid, group, picking, move_line, invoice_id, + invoice_vals, context=None + ): res = super(stock_picking, self)._prepare_invoice_line(cr, uid, group, picking, @@ -53,7 +55,9 @@ def _prepare_invoice_line(self, cr, uid, group, picking, move_line, invoice_id, class sale_order(orm.Model): _inherit = 'sale.order' - def _prepare_order_line_move(self, cr, uid, order, line, picking_id, date_planned, context=None): + def _prepare_order_line_move( + self, cr, uid, order, line, picking_id, date_planned, context=None + ): res = super(sale_order, self)._prepare_order_line_move(cr, uid, order, line, From 7db620c08b1f7eab4d38d6d9fd49f70a2941a136 Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Thu, 7 Aug 2014 15:19:35 +0200 Subject: [PATCH 6/8] [FIX] Still some PEP8 erros --- sale_cancel_reason/model/sale.py | 1 - sale_condition_text/condition.py | 1 - sale_condition_text/sale_order.py | 1 + sale_dropshipping/purchase.py | 4 ++-- sale_quotation_number/sale_quotation.py | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/sale_cancel_reason/model/sale.py b/sale_cancel_reason/model/sale.py index 93e28793bf5..09ac3a7d264 100644 --- a/sale_cancel_reason/model/sale.py +++ b/sale_cancel_reason/model/sale.py @@ -20,7 +20,6 @@ # from openerp.osv import orm, fields -from openerp.tools.translate import _ class sale_order(orm.Model): diff --git a/sale_condition_text/condition.py b/sale_condition_text/condition.py index d72f1692882..c17f088f6cc 100644 --- a/sale_condition_text/condition.py +++ b/sale_condition_text/condition.py @@ -5,7 +5,6 @@ # # from osv import osv, fields -import pooler class AccountConditionText(osv.osv): diff --git a/sale_condition_text/sale_order.py b/sale_condition_text/sale_order.py index 796ffd1e614..1016a0ec92b 100644 --- a/sale_condition_text/sale_order.py +++ b/sale_condition_text/sale_order.py @@ -5,6 +5,7 @@ # # from osv import osv, fields +from openerp.tools.translate import _ class SaleOrder(osv.osv): diff --git a/sale_dropshipping/purchase.py b/sale_dropshipping/purchase.py index b900dcbe710..ff7ea2e3f45 100644 --- a/sale_dropshipping/purchase.py +++ b/sale_dropshipping/purchase.py @@ -95,8 +95,8 @@ def action_picking_create(self, cr, uid, ids, context=None): if purchase.sale_flow == 'direct_delivery': if ( purchase.sale_id - and purchase.sale_id.order_policy == 'picking') - : + and purchase.sale_id.order_policy == 'picking' + ): invoice_control = '2binvoiced' else: invoice_control = 'none' diff --git a/sale_quotation_number/sale_quotation.py b/sale_quotation_number/sale_quotation.py index c7bd8506856..0edbc4f84b7 100644 --- a/sale_quotation_number/sale_quotation.py +++ b/sale_quotation_number/sale_quotation.py @@ -19,7 +19,7 @@ # # -from openerp.osv import fields, orm +from openerp.osv import orm class sale_order(orm.Model): From 1eac03eb8f671178ed15f05ecc50e4a4a81c7150 Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Thu, 7 Aug 2014 15:32:23 +0200 Subject: [PATCH 7/8] [ADD] missing dep --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ab4516585a9..39f2ddfeb2d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,9 @@ env: virtualenv: system_site_packages: true +before_install: + - git clone https://github.com/OCA/product-attribute $HOME/product-attribute -b 7.0 + install: - git clone https://github.com/OCA/maintainer-quality-tools.git ${HOME}/maintainer-quality-tools - export PATH=${HOME}/maintainer-quality-tools/travis:${PATH} @@ -17,7 +20,7 @@ install: script: - travis_run_flake8 - - travis_run_tests + - travis_run_tests $HOME/product-attribute after_success: coveralls From dab683c346ea6dde61cf4749c5619263b331bdee Mon Sep 17 00:00:00 2001 From: Lorenzo Battistini Date: Thu, 7 Aug 2014 16:26:34 +0200 Subject: [PATCH 8/8] [FIX] $HOME/product-attribute should no longer be needed --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 39f2ddfeb2d..48cb839795a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ install: script: - travis_run_flake8 - - travis_run_tests $HOME/product-attribute + - travis_run_tests after_success: coveralls