From 2f8c9a543c24c95f15dcec35b7196205bba1651f Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Fri, 17 Oct 2014 10:13:46 +0200 Subject: [PATCH 1/9] move logistic_requisition_budget out of __unported__ --- .../__init__.py | 0 .../__openerp__.py | 2 +- .../i18n/en_US.po | 0 .../i18n/logistic_requisition_budget.pot | 0 .../model/__init__.py | 0 .../model/logistic_requisition.py | 0 .../report/logistic_requisition.mako | 0 .../report/logistic_requisition_report.xml | 0 .../test/requisition_create_cost_estimate.yml | 0 .../tests/__init__.py | 0 .../tests/test_purchase_split_requisition.py | 0 .../view/logistic_requisition.xml | 0 .../wizard/__init__.py | 0 .../wizard/cost_estimate.py | 0 14 files changed, 1 insertion(+), 1 deletion(-) rename {__unported__/logistic_requisition_budget => logistic_requisition_budget}/__init__.py (100%) rename {__unported__/logistic_requisition_budget => logistic_requisition_budget}/__openerp__.py (98%) rename {__unported__/logistic_requisition_budget => logistic_requisition_budget}/i18n/en_US.po (100%) rename {__unported__/logistic_requisition_budget => logistic_requisition_budget}/i18n/logistic_requisition_budget.pot (100%) rename {__unported__/logistic_requisition_budget => logistic_requisition_budget}/model/__init__.py (100%) rename {__unported__/logistic_requisition_budget => logistic_requisition_budget}/model/logistic_requisition.py (100%) rename {__unported__/logistic_requisition_budget => logistic_requisition_budget}/report/logistic_requisition.mako (100%) rename {__unported__/logistic_requisition_budget => logistic_requisition_budget}/report/logistic_requisition_report.xml (100%) rename {__unported__/logistic_requisition_budget => logistic_requisition_budget}/test/requisition_create_cost_estimate.yml (100%) rename {__unported__/logistic_requisition_budget => logistic_requisition_budget}/tests/__init__.py (100%) rename {__unported__/logistic_requisition_budget => logistic_requisition_budget}/tests/test_purchase_split_requisition.py (100%) rename {__unported__/logistic_requisition_budget => logistic_requisition_budget}/view/logistic_requisition.xml (100%) rename {__unported__/logistic_requisition_budget => logistic_requisition_budget}/wizard/__init__.py (100%) rename {__unported__/logistic_requisition_budget => logistic_requisition_budget}/wizard/cost_estimate.py (100%) diff --git a/__unported__/logistic_requisition_budget/__init__.py b/logistic_requisition_budget/__init__.py similarity index 100% rename from __unported__/logistic_requisition_budget/__init__.py rename to logistic_requisition_budget/__init__.py diff --git a/__unported__/logistic_requisition_budget/__openerp__.py b/logistic_requisition_budget/__openerp__.py similarity index 98% rename from __unported__/logistic_requisition_budget/__openerp__.py rename to logistic_requisition_budget/__openerp__.py index b3bec949..810d2e86 100644 --- a/__unported__/logistic_requisition_budget/__openerp__.py +++ b/logistic_requisition_budget/__openerp__.py @@ -49,5 +49,5 @@ "auto_install": False, "test": ['test/requisition_create_cost_estimate.yml', ], - 'installable': False, + 'installable': True, } diff --git a/__unported__/logistic_requisition_budget/i18n/en_US.po b/logistic_requisition_budget/i18n/en_US.po similarity index 100% rename from __unported__/logistic_requisition_budget/i18n/en_US.po rename to logistic_requisition_budget/i18n/en_US.po diff --git a/__unported__/logistic_requisition_budget/i18n/logistic_requisition_budget.pot b/logistic_requisition_budget/i18n/logistic_requisition_budget.pot similarity index 100% rename from __unported__/logistic_requisition_budget/i18n/logistic_requisition_budget.pot rename to logistic_requisition_budget/i18n/logistic_requisition_budget.pot diff --git a/__unported__/logistic_requisition_budget/model/__init__.py b/logistic_requisition_budget/model/__init__.py similarity index 100% rename from __unported__/logistic_requisition_budget/model/__init__.py rename to logistic_requisition_budget/model/__init__.py diff --git a/__unported__/logistic_requisition_budget/model/logistic_requisition.py b/logistic_requisition_budget/model/logistic_requisition.py similarity index 100% rename from __unported__/logistic_requisition_budget/model/logistic_requisition.py rename to logistic_requisition_budget/model/logistic_requisition.py diff --git a/__unported__/logistic_requisition_budget/report/logistic_requisition.mako b/logistic_requisition_budget/report/logistic_requisition.mako similarity index 100% rename from __unported__/logistic_requisition_budget/report/logistic_requisition.mako rename to logistic_requisition_budget/report/logistic_requisition.mako diff --git a/__unported__/logistic_requisition_budget/report/logistic_requisition_report.xml b/logistic_requisition_budget/report/logistic_requisition_report.xml similarity index 100% rename from __unported__/logistic_requisition_budget/report/logistic_requisition_report.xml rename to logistic_requisition_budget/report/logistic_requisition_report.xml diff --git a/__unported__/logistic_requisition_budget/test/requisition_create_cost_estimate.yml b/logistic_requisition_budget/test/requisition_create_cost_estimate.yml similarity index 100% rename from __unported__/logistic_requisition_budget/test/requisition_create_cost_estimate.yml rename to logistic_requisition_budget/test/requisition_create_cost_estimate.yml diff --git a/__unported__/logistic_requisition_budget/tests/__init__.py b/logistic_requisition_budget/tests/__init__.py similarity index 100% rename from __unported__/logistic_requisition_budget/tests/__init__.py rename to logistic_requisition_budget/tests/__init__.py diff --git a/__unported__/logistic_requisition_budget/tests/test_purchase_split_requisition.py b/logistic_requisition_budget/tests/test_purchase_split_requisition.py similarity index 100% rename from __unported__/logistic_requisition_budget/tests/test_purchase_split_requisition.py rename to logistic_requisition_budget/tests/test_purchase_split_requisition.py diff --git a/__unported__/logistic_requisition_budget/view/logistic_requisition.xml b/logistic_requisition_budget/view/logistic_requisition.xml similarity index 100% rename from __unported__/logistic_requisition_budget/view/logistic_requisition.xml rename to logistic_requisition_budget/view/logistic_requisition.xml diff --git a/__unported__/logistic_requisition_budget/wizard/__init__.py b/logistic_requisition_budget/wizard/__init__.py similarity index 100% rename from __unported__/logistic_requisition_budget/wizard/__init__.py rename to logistic_requisition_budget/wizard/__init__.py diff --git a/__unported__/logistic_requisition_budget/wizard/cost_estimate.py b/logistic_requisition_budget/wizard/cost_estimate.py similarity index 100% rename from __unported__/logistic_requisition_budget/wizard/cost_estimate.py rename to logistic_requisition_budget/wizard/cost_estimate.py From 3938c800af783fd3c7b0e8b2b8755c5cb3cc3064 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Fri, 17 Oct 2014 14:07:58 +0200 Subject: [PATCH 2/9] set proper license headers --- logistic_requisition_budget/__init__.py | 11 +++++------ logistic_requisition_budget/__openerp__.py | 16 +++++++--------- logistic_requisition_budget/model/__init__.py | 18 ++++++++---------- .../model/logistic_requisition.py | 14 ++++++-------- logistic_requisition_budget/wizard/__init__.py | 14 +++++++------- .../wizard/cost_estimate.py | 13 ++++++------- 6 files changed, 39 insertions(+), 47 deletions(-) diff --git a/logistic_requisition_budget/__init__.py b/logistic_requisition_budget/__init__.py index f70e50d0..bb8a6f4c 100644 --- a/logistic_requisition_budget/__init__.py +++ b/logistic_requisition_budget/__init__.py @@ -1,22 +1,21 @@ # -*- coding: utf-8 -*- -############################################################################## # # Author: Romain Deheele # Copyright 2014 Camptocamp SA # # 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 by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more description. +# 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 . # -############################################################################## +# from . import model from . import wizard diff --git a/logistic_requisition_budget/__openerp__.py b/logistic_requisition_budget/__openerp__.py index 810d2e86..f006a62a 100644 --- a/logistic_requisition_budget/__openerp__.py +++ b/logistic_requisition_budget/__openerp__.py @@ -1,24 +1,22 @@ # -*- coding: utf-8 -*- -############################################################################## # -# Author: Joël Grand-Guillaume, Jacques-Etienne Baudoux, Guewen Baconnier -# Copyright 2013 Camptocamp SA +# Author: Joël Grand-Guillaume, Jacques-Etienne Baudoux, Guewen Baconnier +# Copyright 2013-2014 Camptocamp SA # # 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 by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more description. +# 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 . # -############################################################################## - +# {"name": "Logistic Requisition Budget", "version": "0.1", "author": "Camptocamp", diff --git a/logistic_requisition_budget/model/__init__.py b/logistic_requisition_budget/model/__init__.py index 0b1b23e9..8a269c23 100644 --- a/logistic_requisition_budget/model/__init__.py +++ b/logistic_requisition_budget/model/__init__.py @@ -1,23 +1,21 @@ # -*- coding: utf-8 -*- -############################################################################## # -# Author: Joël Grand-Guillaume, Jacques-Etienne Baudoux, Guewen Baconnier, -# Romain Deheele -# Copyright 2013 Camptocamp SA +# Author: Joël Grand-Guillaume, Jacques-Etienne Baudoux, Guewen Baconnier, +# Romain Deheele +# Copyright 2013-2014 Camptocamp SA # # 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 by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more description. +# 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 . # -############################################################################## - +# from . import logistic_requisition diff --git a/logistic_requisition_budget/model/logistic_requisition.py b/logistic_requisition_budget/model/logistic_requisition.py index 495c952d..3d09558b 100644 --- a/logistic_requisition_budget/model/logistic_requisition.py +++ b/logistic_requisition_budget/model/logistic_requisition.py @@ -1,24 +1,22 @@ # -*- coding: utf-8 -*- -############################################################################## # -# Author: Romain Deheele +# Author: Romain Deheele # Copyright 2014 Camptocamp SA # # 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 by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more description. +# 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 . # -############################################################################## - +# import logging import time diff --git a/logistic_requisition_budget/wizard/__init__.py b/logistic_requisition_budget/wizard/__init__.py index cc99010d..402f45b5 100644 --- a/logistic_requisition_budget/wizard/__init__.py +++ b/logistic_requisition_budget/wizard/__init__.py @@ -1,21 +1,21 @@ # -*- coding: utf-8 -*- -############################################################################## # -# Author: Joël Grand-Guillaume +# Author: Joël Grand-Guillaume # Copyright 2013 Camptocamp SA # # 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 by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more description. +# 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 . # -############################################################################## +# +# -*- coding: utf-8 -*- from . import cost_estimate diff --git a/logistic_requisition_budget/wizard/cost_estimate.py b/logistic_requisition_budget/wizard/cost_estimate.py index 14fc9181..03a35e7a 100644 --- a/logistic_requisition_budget/wizard/cost_estimate.py +++ b/logistic_requisition_budget/wizard/cost_estimate.py @@ -1,23 +1,22 @@ # -*- coding: utf-8 -*- -############################################################################## # -# Author: Joël Grand-Guillaume +# Author: Joël Grand-Guillaume # Copyright 2013 Camptocamp SA # # 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 by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more description. +# 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 . # -############################################################################## +# from openerp.osv import fields, orm from openerp.tools.translate import _ From 84ce931c55b47d352edbb1403150bb2f4d755fc4 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Fri, 17 Oct 2014 14:15:29 +0200 Subject: [PATCH 3/9] [PEP8] --- .../model/logistic_requisition.py | 15 ++++++++++----- .../tests/test_purchase_split_requisition.py | 14 ++++++++------ .../wizard/cost_estimate.py | 2 +- 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/logistic_requisition_budget/model/logistic_requisition.py b/logistic_requisition_budget/model/logistic_requisition.py index 3d09558b..aaf60f56 100644 --- a/logistic_requisition_budget/model/logistic_requisition.py +++ b/logistic_requisition_budget/model/logistic_requisition.py @@ -44,8 +44,10 @@ class logistic_requisition(orm.Model): lambda self, cr, uid, ids, c=None: ids, ['line_ids'], 20), 'logistic.requisition.line': ( - lambda self, *a, **kw: self._store_get_requisition_ids(*a, **kw), - ['requested_qty', 'budget_unit_price', 'budget_tot_price', 'requisition_id'], 20), + lambda self, *a, **kw: self._store_get_requisition_ids( + *a, **kw), + ['requested_qty', 'budget_unit_price', + 'budget_tot_price', 'requisition_id'], 20), }), 'allowed_budget': fields.boolean('Allowed Budget'), 'budget_holder_id': fields.many2one( @@ -90,7 +92,8 @@ def copy(self, cr, uid, id, default=None, context=None): 'finance_officer_id': False, 'date_finance_officer': False, }) - return super(logistic_requisition, self).copy(cr, uid, id, default=default, context=context) + return super(logistic_requisition, self + ).copy(cr, uid, id, default=default, context=context) def onchange_validate(self, cr, uid, ids, validate_id, date_validate, date_field_name, context=None): @@ -121,7 +124,8 @@ class logistic_requisition_line(orm.Model): states=REQUEST_STATES, digits_compute=dp.get_precision('Account')), 'budget_unit_price': fields.function( - lambda self, *args, **kwargs: self._get_unit_amount_line(*args, **kwargs), + lambda self, *args, **kwargs: self._get_unit_amount_line( + *args, **kwargs), string='Budget Unit Price', type="float", digits_compute=dp.get_precision('Account'), @@ -141,7 +145,8 @@ class logistic_requisition_source(orm.Model): _inherit = "logistic.requisition.source" _constraints = [ - (lambda self, *a, **kw: self._check_source_lines_total_amount(*a, **kw), + (lambda self, *a, **kw: self._check_source_lines_total_amount( + *a, **kw), 'The total cost cannot be more than the total budget.', ['proposed_qty', 'unit_cost', 'requisition_line_id']), ] diff --git a/logistic_requisition_budget/tests/test_purchase_split_requisition.py b/logistic_requisition_budget/tests/test_purchase_split_requisition.py index bdbe5c87..e8f6d390 100644 --- a/logistic_requisition_budget/tests/test_purchase_split_requisition.py +++ b/logistic_requisition_budget/tests/test_purchase_split_requisition.py @@ -20,7 +20,6 @@ ############################################################################## import time -import unittest2 from functools import partial from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as D_FMT @@ -71,8 +70,8 @@ def setUp(self): __, self.user_demo = self.get_ref('base', 'user_demo') __, self.product_7 = self.get_ref('product', 'product_product_7') __, self.product_uom_pce = self.get_ref('product', 'product_uom_unit') - __, self.pricelist_sale = self.get_ref('product','list0') - + __, self.pricelist_sale = self.get_ref('product', 'list0') + vals = { 'partner_id': self.partner_4, 'consignee_id': self.partner_3, @@ -112,7 +111,8 @@ def setUp(self): 'Product Unit of Measure') def test_split_too_many_products_selected_budget_exceeded(self): - """ Create a call for bids from the logistic requisition, 2 po line choosed (budget exceeded) + """ Create a call for bids from the logistic requisition, 2 po line + choosed (budget exceeded) 30 items in a first purchase order and 80 items in a second one, for a total of 110 items. That means 110 products have been ordered @@ -122,15 +122,17 @@ def test_split_too_many_products_selected_budget_exceeded(self): We should not be able to propose more than requested financially. """ # create a first draft bid and select a part of the line - purchase1, bid_line1 = purchase_requisition.create_draft_purchase_order( + po_draft = purchase_requisition.create_draft_purchase_order( self, self.purchase_requisition.id, self.partner_1) + purchase1, bid_line1 = po_draft bid_line1.write({'price_unit': 15}) purchase_order.select_line(self, bid_line1.id, 30) purchase_order.bid_encoded(self, purchase1.id) # create a second draft bid and select a part of the line - purchase2, bid_line2 = purchase_requisition.create_draft_purchase_order( + po_draft = purchase_requisition.create_draft_purchase_order( self, self.purchase_requisition.id, self.partner_12) + purchase2, bid_line2 = po_draft bid_line2.write({'price_unit': 13}) purchase_order.select_line(self, bid_line2.id, 80) purchase_order.bid_encoded(self, purchase2.id) diff --git a/logistic_requisition_budget/wizard/cost_estimate.py b/logistic_requisition_budget/wizard/cost_estimate.py index 03a35e7a..d9f666a9 100644 --- a/logistic_requisition_budget/wizard/cost_estimate.py +++ b/logistic_requisition_budget/wizard/cost_estimate.py @@ -17,7 +17,7 @@ # along with this program. If not, see . # # -from openerp.osv import fields, orm +from openerp.osv import orm from openerp.tools.translate import _ From 4b360c1ea6a604931aa9b82625f816ca286a0e28 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Fri, 17 Oct 2014 14:22:37 +0200 Subject: [PATCH 4/9] port report to Qweb --- logistic_requisition_budget/__openerp__.py | 2 +- .../report/logistic_requisition.mako | 226 ------------------ .../report/logistic_requisition_report.xml | 13 - .../view/report_logistic_requisition.xml | 44 ++++ 4 files changed, 45 insertions(+), 240 deletions(-) delete mode 100644 logistic_requisition_budget/report/logistic_requisition.mako delete mode 100644 logistic_requisition_budget/report/logistic_requisition_report.xml create mode 100644 logistic_requisition_budget/view/report_logistic_requisition.xml diff --git a/logistic_requisition_budget/__openerp__.py b/logistic_requisition_budget/__openerp__.py index f006a62a..24d85d6a 100644 --- a/logistic_requisition_budget/__openerp__.py +++ b/logistic_requisition_budget/__openerp__.py @@ -42,7 +42,7 @@ ], "demo": [], "data": ["view/logistic_requisition.xml", - "report/logistic_requisition_report.xml", + "view/report_logistic_requisition.xml", ], "auto_install": False, "test": ['test/requisition_create_cost_estimate.yml', diff --git a/logistic_requisition_budget/report/logistic_requisition.mako b/logistic_requisition_budget/report/logistic_requisition.mako deleted file mode 100644 index 4f5950d3..00000000 --- a/logistic_requisition_budget/report/logistic_requisition.mako +++ /dev/null @@ -1,226 +0,0 @@ - - - - - - <%page expression_filter="entity"/> - <% - def carriage_returns(text): - return text.replace('\n', '
') - - %> - %for requisition in objects: - <% setLang(requisition.partner_id.lang) %> - -
- - %if requisition.partner_id.parent_id: - - - <% address_lines = requisition.partner_id.contact_address.split("\n")[1:] %> - %else: - - <% address_lines = requisition.partner_id.contact_address.split("\n") %> - %endif - %for part in address_lines: - %if part: - - %endif - %endfor -
${requisition.partner_id.parent_id.name or ''}
${requisition.partner_id.title.name if requisition.partner_id.title else ''} ${requisition.partner_id.name }
${requisition.partner_id.title.name if requisition.partner_id.title else ''} ${requisition.partner_id.name }
${part}
- - - - %if requisition.consignee_shipping_id.parent_id: - - - <% address_lines = requisition.consignee_shipping_id.contact_address.split("\n")[1:] %> - %else: - - <% address_lines = requisition.consignee_shipping_id.contact_address.split("\n") %> - %endif - %for part in address_lines: - %if part: - - %endif - %endfor -
${_("Shipping address:")}
${requisition.consignee_shipping_id.parent_id.name or ''}
${requisition.consignee_shipping_id.title.name if requisition.consignee_shipping_id.title else ''} ${requisition.consignee_shipping_id.name }
${requisition.consignee_shipping_id.title and requisition.consignee_shipping_id.title.name or ''} ${requisition.consignee_shipping_id.name }
${part}
- - - - %if requisition.consignee_id.parent_id: - - - <% address_lines = requisition.consignee_id.contact_address.split("\n")[1:] %> - %else: - - <% address_lines = requisition.consignee_id.contact_address.split("\n") %> - %endif - %for part in address_lines: - %if part: - - %endif - %endfor -
${_("Consignee address:")}
${requisition.consignee_id.parent_id.name or ''}
${requisition.consignee_id.title.name if requisition.consignee_id.title else ''} ${requisition.consignee_id.name }
${requisition.consignee_id.title.name if requisition.consignee_id.title else ''} ${requisition.consignee_id.name }
${part}
-
- -

${_('Logistic requisition')} ${requisition.name}

- - - - - - - - - - - - - - - - - -
${_("Desired delivery date")}${_("Preferred transport")}${_("Cost estimate only")}${_("Project")}${_("Country")}${_("Requisition Date")}
${formatLang(requisition.date_delivery, date=True)}${requisition.preferred_transport.name if requisition.preferred_transport else ''}${_("Yes") if requisition.cost_estimate_only else _("No")}${requisition.analytic_id.name if requisition.analytic_id else ''}${requisition.country_id.name}${formatLang(requisition.date, date=True)}
-
- - - - - - - - - - - - %for line in requisition.line_ids: - - - - - - - %endfor - -
${_("Number")}${_("Description")}${_("Quantity")}${_("UoM")}
${line.name}${(line.product_id.code or '') if line.product_id else ''} ${line.product_id.name if line.product_id else ''}${formatLang(line.requested_qty)}${line.requested_uom_id.category_id.name}
- %if requisition.shipping_note : -

${_('Delivery Remarks')}

-

${requisition.note | carriage_returns}

- %endif - %if requisition.note : -

${_("General Remarks")}

-

${requisition.note | carriage_returns}

- %endif -
-
-

${_("Approval")}

- - - - - - - - - - - -
${_("Requesting entity")}${_("Requested date")}${_("Signature")}
${requisition.partner_id.name}${requisition.date or 'N/A'} 
-

${_("Budget")}

-

${_("Budget limit:")} ${formatLang(requisition.allowed_budget)}

- - - - - - - %if requisition.budget_holder_id: - - - - - - %endif - %if requisition.finance_officer_id: - - - - - - %endif -
${_("Budget/financial holder")}${_("Validation date")}${_("Signature")}
${requisition.budget_holder_id.name}${requisition.date_budget_holder if requisition.date_budget_holder else 'N/A'} 
${requisition.finance_officer_id.name}${requisition.date_finance_officer if requisition.date_finance_officer else 'N/A'} 
-

- %endfor - - diff --git a/logistic_requisition_budget/report/logistic_requisition_report.xml b/logistic_requisition_budget/report/logistic_requisition_report.xml deleted file mode 100644 index 585132ac..00000000 --- a/logistic_requisition_budget/report/logistic_requisition_report.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - diff --git a/logistic_requisition_budget/view/report_logistic_requisition.xml b/logistic_requisition_budget/view/report_logistic_requisition.xml new file mode 100644 index 00000000..bc0a6b86 --- /dev/null +++ b/logistic_requisition_budget/view/report_logistic_requisition.xml @@ -0,0 +1,44 @@ + + + + + + + From c007ffc380f33e415edf6bebcc99a6efda148c9c Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Fri, 17 Oct 2014 16:54:09 +0200 Subject: [PATCH 5/9] remove spaces in xml --- logistic_requisition_budget/view/logistic_requisition.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/logistic_requisition_budget/view/logistic_requisition.xml b/logistic_requisition_budget/view/logistic_requisition.xml index 2ffc41c3..e607afef 100644 --- a/logistic_requisition_budget/view/logistic_requisition.xml +++ b/logistic_requisition_budget/view/logistic_requisition.xml @@ -73,7 +73,7 @@ logistic.requisition.line.budget.form logistic.requisition.line - + - + From 7f99184ce6965fe01a1457e615db6982cde39602 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Tue, 21 Oct 2014 17:23:41 +0200 Subject: [PATCH 6/9] rename module to logistic_budget --- .../__init__.py | 0 .../__openerp__.py | 8 ++++---- .../i18n/en_US.po | 0 .../i18n/logistic_requisition_budget.pot | 0 .../model/__init__.py | 0 .../model/logistic_requisition.py | 0 .../test/requisition_create_cost_estimate.yml | 0 .../tests/__init__.py | 0 .../tests/test_purchase_split_requisition.py | 0 .../view/logistic_requisition.xml | 0 .../view/report_logistic_requisition.xml | 0 .../wizard/__init__.py | 0 .../wizard/cost_estimate.py | 0 13 files changed, 4 insertions(+), 4 deletions(-) rename {logistic_requisition_budget => logistic_budget}/__init__.py (100%) rename {logistic_requisition_budget => logistic_budget}/__openerp__.py (90%) rename {logistic_requisition_budget => logistic_budget}/i18n/en_US.po (100%) rename {logistic_requisition_budget => logistic_budget}/i18n/logistic_requisition_budget.pot (100%) rename {logistic_requisition_budget => logistic_budget}/model/__init__.py (100%) rename {logistic_requisition_budget => logistic_budget}/model/logistic_requisition.py (100%) rename {logistic_requisition_budget => logistic_budget}/test/requisition_create_cost_estimate.yml (100%) rename {logistic_requisition_budget => logistic_budget}/tests/__init__.py (100%) rename {logistic_requisition_budget => logistic_budget}/tests/test_purchase_split_requisition.py (100%) rename {logistic_requisition_budget => logistic_budget}/view/logistic_requisition.xml (100%) rename {logistic_requisition_budget => logistic_budget}/view/report_logistic_requisition.xml (100%) rename {logistic_requisition_budget => logistic_budget}/wizard/__init__.py (100%) rename {logistic_requisition_budget => logistic_budget}/wizard/cost_estimate.py (100%) diff --git a/logistic_requisition_budget/__init__.py b/logistic_budget/__init__.py similarity index 100% rename from logistic_requisition_budget/__init__.py rename to logistic_budget/__init__.py diff --git a/logistic_requisition_budget/__openerp__.py b/logistic_budget/__openerp__.py similarity index 90% rename from logistic_requisition_budget/__openerp__.py rename to logistic_budget/__openerp__.py index 24d85d6a..f9ab7649 100644 --- a/logistic_requisition_budget/__openerp__.py +++ b/logistic_budget/__openerp__.py @@ -17,7 +17,7 @@ # along with this program. If not, see . # # -{"name": "Logistic Requisition Budget", +{"name": "Logistic Budget", "version": "0.1", "author": "Camptocamp", "license": "AGPL-3", @@ -26,10 +26,10 @@ "images": [], "website": "http://www.camptocamp.com", "description": """ -This logisitc requisiton budget -=============================== +Logisitic budget +================ -This module add a notion of budget on logistic requisition. +This module adds a notion of budget on logistic requisition. Each requisition lines have now a budget holder and a budget Value. Requisiton must be approves by budget manager. diff --git a/logistic_requisition_budget/i18n/en_US.po b/logistic_budget/i18n/en_US.po similarity index 100% rename from logistic_requisition_budget/i18n/en_US.po rename to logistic_budget/i18n/en_US.po diff --git a/logistic_requisition_budget/i18n/logistic_requisition_budget.pot b/logistic_budget/i18n/logistic_requisition_budget.pot similarity index 100% rename from logistic_requisition_budget/i18n/logistic_requisition_budget.pot rename to logistic_budget/i18n/logistic_requisition_budget.pot diff --git a/logistic_requisition_budget/model/__init__.py b/logistic_budget/model/__init__.py similarity index 100% rename from logistic_requisition_budget/model/__init__.py rename to logistic_budget/model/__init__.py diff --git a/logistic_requisition_budget/model/logistic_requisition.py b/logistic_budget/model/logistic_requisition.py similarity index 100% rename from logistic_requisition_budget/model/logistic_requisition.py rename to logistic_budget/model/logistic_requisition.py diff --git a/logistic_requisition_budget/test/requisition_create_cost_estimate.yml b/logistic_budget/test/requisition_create_cost_estimate.yml similarity index 100% rename from logistic_requisition_budget/test/requisition_create_cost_estimate.yml rename to logistic_budget/test/requisition_create_cost_estimate.yml diff --git a/logistic_requisition_budget/tests/__init__.py b/logistic_budget/tests/__init__.py similarity index 100% rename from logistic_requisition_budget/tests/__init__.py rename to logistic_budget/tests/__init__.py diff --git a/logistic_requisition_budget/tests/test_purchase_split_requisition.py b/logistic_budget/tests/test_purchase_split_requisition.py similarity index 100% rename from logistic_requisition_budget/tests/test_purchase_split_requisition.py rename to logistic_budget/tests/test_purchase_split_requisition.py diff --git a/logistic_requisition_budget/view/logistic_requisition.xml b/logistic_budget/view/logistic_requisition.xml similarity index 100% rename from logistic_requisition_budget/view/logistic_requisition.xml rename to logistic_budget/view/logistic_requisition.xml diff --git a/logistic_requisition_budget/view/report_logistic_requisition.xml b/logistic_budget/view/report_logistic_requisition.xml similarity index 100% rename from logistic_requisition_budget/view/report_logistic_requisition.xml rename to logistic_budget/view/report_logistic_requisition.xml diff --git a/logistic_requisition_budget/wizard/__init__.py b/logistic_budget/wizard/__init__.py similarity index 100% rename from logistic_requisition_budget/wizard/__init__.py rename to logistic_budget/wizard/__init__.py diff --git a/logistic_requisition_budget/wizard/cost_estimate.py b/logistic_budget/wizard/cost_estimate.py similarity index 100% rename from logistic_requisition_budget/wizard/cost_estimate.py rename to logistic_budget/wizard/cost_estimate.py From db86dccb242bad5ec920abf3ac1d6a12ebe734a4 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Wed, 22 Oct 2014 16:13:20 +0200 Subject: [PATCH 7/9] remove account_code as too specific --- logistic_budget/test/requisition_create_cost_estimate.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/logistic_budget/test/requisition_create_cost_estimate.yml b/logistic_budget/test/requisition_create_cost_estimate.yml index 0729c7f2..a3f5ad41 100644 --- a/logistic_budget/test/requisition_create_cost_estimate.yml +++ b/logistic_budget/test/requisition_create_cost_estimate.yml @@ -91,8 +91,6 @@ except orm.except_orm as err: assert 'NO_BUDGET_VALID' in err.error_codes, ( 'Expected an error because the budget holder is missing') - assert 'NO_ACCOUNT_CODE' in err.error_codes, ( - 'Expected an error because the account code is missing') else: raise AssertionError('Expected an orm.except_orm error, got nothing') - @@ -100,12 +98,6 @@ - !record {model: logistic.requisition, id: logistic_requisition_cost_estimate_01}: budget_holder_id: base.user_demo -- - !record {model: logistic.requisition.line, id: logistic_requisition_line_cost_estimate_01}: - account_code: 'XXXX' -- - !record {model: logistic.requisition.line, id: logistic_requisition_line_cost_estimate_02}: - account_code: 'YYYY' - I open the wizard to create a cost estimate from the logistic requisition - From 9312e1edfc21e682c464860bc9acaaaee8f6a831 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Fri, 31 Oct 2014 11:11:40 +0100 Subject: [PATCH 8/9] fix tests --- .../test/requisition_create_cost_estimate.yml | 81 +++++------- .../tests/test_purchase_split_requisition.py | 115 +++++++++--------- 2 files changed, 88 insertions(+), 108 deletions(-) diff --git a/logistic_budget/test/requisition_create_cost_estimate.yml b/logistic_budget/test/requisition_create_cost_estimate.yml index a3f5ad41..f537a514 100644 --- a/logistic_budget/test/requisition_create_cost_estimate.yml +++ b/logistic_budget/test/requisition_create_cost_estimate.yml @@ -15,7 +15,8 @@ - !record {model: logistic.requisition.line, id: logistic_requisition_line_cost_estimate_01}: requisition_id: logistic_requisition_cost_estimate_01 - product_id: product.product_product_7 + product_id: product.product_product_32 + description: "[HEAD] Headset standard" requested_qty: 100 requested_uom_id: product.product_uom_unit date_delivery: !eval "time.strftime('%Y-%m-%d')" @@ -27,19 +28,19 @@ !record {model: logistic.requisition.source, id: logistic_requisition_source_cost_estimate_01}: requisition_line_id: logistic_requisition_line_cost_estimate_01 proposed_qty: 110 - proposed_product_id: product.product_product_7 + proposed_product_id: product.product_product_32 proposed_uom_id: product.product_uom_unit unit_cost: 8 - transport_applicable: 0 procurement_method: wh_dispatch price_is: fixed - dispatch_location_id: stock.stock_location_shop1 + dispatch_location_id: stock.stock_location_components - And I add a line 2 - !record {model: logistic.requisition.line, id: logistic_requisition_line_cost_estimate_02}: requisition_id: logistic_requisition_cost_estimate_01 - product_id: product.product_product_8 + product_id: product.product_product_25 + description: "[LAP-E5] Laptop E5023" requested_qty: 100 requested_uom_id: product.product_uom_unit date_delivery: !eval "time.strftime('%Y-%m-%d')" @@ -51,19 +52,17 @@ !record {model: logistic.requisition.source, id: logistic_requisition_source_cost_estimate_02}: requisition_line_id: logistic_requisition_line_cost_estimate_02 proposed_qty: 90 - proposed_product_id: product.product_product_8 + proposed_product_id: product.product_product_25 proposed_uom_id: product.product_uom_unit unit_cost: 8 - transport_applicable: 0 procurement_method: wh_dispatch price_is: estimated - dispatch_location_id: stock.stock_location_shop1 + dispatch_location_id: stock.stock_location_components - When I confirm the logistic requisition - - !python {model: logistic.requisition}: | - req = self.browse(cr, uid, ref("logistic_requisition_cost_estimate_01")) - req.button_confirm() + !python {model: logistic.requisition, id: logistic_requisition_cost_estimate_01}: | + self.button_confirm() - And I source the lines - @@ -71,10 +70,6 @@ line1_id = ref("logistic_requisition_line_cost_estimate_01") line2_id = ref("logistic_requisition_line_cost_estimate_02") ids = [line1_id, line2_id] - # The initial yaml does not set it to false, probably - # a bug related to the application of the default values - # However, we need to not have this flag to source the lines - self.write(cr, uid, ids, {'transport_applicable': False}) self.button_sourced(cr, uid, ids) - I open the wizard to create a cost estimate from the logistic requisition, @@ -87,7 +82,7 @@ } wizard_id = self.create(cr, uid, {}, context=context) try: - self.cost_estimate(cr, uid, wizard_id) + self.cost_estimate(cr, uid, [wizard_id]) except orm.except_orm as err: assert 'NO_BUDGET_VALID' in err.error_codes, ( 'Expected an error because the budget holder is missing') @@ -106,7 +101,7 @@ 'active_ids': [ref('logistic_requisition_cost_estimate_01')], } wizard_id = self.create(cr, uid, {}, context=context) - open_action = self.cost_estimate(cr, uid, wizard_id) + open_action = self.cost_estimate(cr, uid, [wizard_id]) cost_estimate_id = open_action['res_id'] cost_estimate_obj = self.pool.get('sale.order') cost_estimate = cost_estimate_obj.browse(cr, uid, cost_estimate_id) @@ -115,31 +110,27 @@ - I check if the information of the logistic requisition are propagated correctly - - !python {model: logistic.requisition}: | - req = self.browse(cr, uid, ref("logistic_requisition_cost_estimate_01")) - sale_obj = self.pool.get('sale.order') - sale_ids = sale_obj.search(cr, uid, [('requisition_id', '=', req.id)]) - assert len(sale_ids) == 1 - sale = sale_obj.browse(cr, uid, sale_ids[0]) - assert sale.partner_id == req.partner_id - assert sale.partner_invoice_id == req.partner_id - assert sale.consignee_id == req.consignee_id - assert sale.incoterm == req.incoterm_id - assert sale.incoterm_address == req.incoterm_address - assert sale.project_id == req.analytic_id + !python {model: logistic.requisition, id: logistic_requisition_cost_estimate_01}: | + sale_obj = self.env['sale.order'] + sale = sale_obj.search([('requisition_id', '=', self.id)]) + sale.ensure_one() + assert sale.partner_id == self.partner_id + assert sale.partner_invoice_id == self.partner_id + assert sale.consignee_id == self.consignee_id + assert sale.incoterm == self.incoterm_id + assert sale.incoterm_address == self.incoterm_address + assert sale.project_id == self.analytic_id - I check if the information of the lines is correct - !python {model: logistic.requisition.source}: | - def check_line(self, cr, uid, line_id): + def check_line(self, cr, uid, source_line_id): # the upper scope is not accessible here, # that's why self, cr, uid are passed as arguments - sale_line_obj = self.pool.get('sale.order.line') - sale_line_ids = sale_line_obj.search( - cr, uid, [('logistic_requisition_source_id', '=', line_id)]) - assert len(sale_line_ids) == 1 - sale_line = sale_line_obj.browse(cr, uid, sale_line_ids[0]) - source = self.browse(cr, uid, line_id) + location_obj = self.pool['stock.location'] + source = self.browse(cr, uid, source_line_id) + sale_lines = source.requisition_id.line_ids[0].cost_estimate_id.order_line + sale_line = [line for line in sale_lines if line.product_id == source.proposed_product_id][0] line = source.requisition_line_id assert sale_line.product_id == source.proposed_product_id, ( "product_id should be %s, received %s" % @@ -164,22 +155,14 @@ assert sale_line.price_is == source.price_is, ( "price_is should be %s, received %s" % (source.price_is, sale_line.price_is)) - assert_type = ('make_to_stock' - if source.procurement_method == 'wh_dispatch' - else 'make_to_order') - assert sale_line.type == assert_type, ( - "Type should be %s, received: %s" % (assert_type, sale_line.type)) - if source.procurement_method != 'wh_dispatch': - assert sale_line.sale_flow == 'direct_delivery', ( - "A line not in 'Warehouse dispatch' should be in direct delivery") - - if source.dispatch_location_id: - assert sale_line.location_id == source.dispatch_location_id, ( + loc = source.dispatch_location_id + if location_obj.get_warehouse(cr, uid, loc): + assert sale_line.warehouse_id.id == location_obj.get_warehouse(cr, uid, loc), ( "dispatch should be %s, received %s" % - (source.dispatch_location_id, sale_line.location_id)) + (location_obj.get_warehouse(cr, uid, loc), sale_line.warehouse_id.id)) else: - assert not sale_line.location_id, ( + assert not sale_line.warehouse_id, ( "No dispatch location on requisition line, but received a " "location in sale order line") diff --git a/logistic_budget/tests/test_purchase_split_requisition.py b/logistic_budget/tests/test_purchase_split_requisition.py index e8f6d390..7f67010b 100644 --- a/logistic_budget/tests/test_purchase_split_requisition.py +++ b/logistic_budget/tests/test_purchase_split_requisition.py @@ -2,7 +2,7 @@ ############################################################################## # # Author: Guewen Baconnier -# Copyright 2013 Camptocamp SA +# Copyright 2013-2014 Camptocamp SA # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as @@ -20,12 +20,10 @@ ############################################################################## import time -from functools import partial from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as D_FMT -from openerp.osv import orm +from openerp import exceptions import openerp.tests.common as common -from openerp import SUPERUSER_ID from openerp.addons.logistic_requisition.tests import logistic_requisition from openerp.addons.logistic_requisition.tests import purchase_requisition from openerp.addons.logistic_requisition.tests import purchase_order @@ -55,60 +53,59 @@ class test_purchase_split_requisition(common.TransactionCase): def setUp(self): super(test_purchase_split_requisition, self).setUp() - cr, uid = self.cr, self.uid - self.ir_model_data = self.registry('ir.model.data') - self.log_req = self.registry('logistic.requisition') - self.log_req_line = self.registry('logistic.requisition.line') - self.purchase_order = self.registry('purchase.order') - self.get_ref = partial(self.ir_model_data.get_object_reference, - self.cr, self.uid) + self.ir_model_data = self.env['ir.model.data'] + self.log_req = self.env['logistic.requisition'] + self.log_req_line = self.env['logistic.requisition.line'] + self.purchase_order = self.env['purchase.order'] - __, self.partner_1 = self.get_ref('base', 'res_partner_1') - __, self.partner_3 = self.get_ref('base', 'res_partner_3') - __, self.partner_4 = self.get_ref('base', 'res_partner_4') - __, self.partner_12 = self.get_ref('base', 'res_partner_12') - __, self.user_demo = self.get_ref('base', 'user_demo') - __, self.product_7 = self.get_ref('product', 'product_product_7') - __, self.product_uom_pce = self.get_ref('product', 'product_uom_unit') - __, self.pricelist_sale = self.get_ref('product', 'list0') + data_model = self.env['ir.model.data'] + self.partner_1 = data_model.xmlid_to_object('base.res_partner_1') + self.partner_3 = data_model.xmlid_to_object('base.res_partner_3') + self.partner_4 = data_model.xmlid_to_object('base.res_partner_4') + self.partner_12 = data_model.xmlid_to_object('base.res_partner_12') + self.user_demo = data_model.xmlid_to_object('base.user_demo') + self.product_32 = data_model.xmlid_to_object( + 'product.product_product_32') + self.product_uom_pce = data_model.xmlid_to_object( + 'product.product_uom_unit') + self.pricelist_sale = data_model.xmlid_to_object('product.list0') vals = { - 'partner_id': self.partner_4, - 'consignee_id': self.partner_3, + 'partner_id': self.partner_4.id, + 'consignee_id': self.partner_3.id, 'date_delivery': time.strftime(D_FMT), - 'user_id': self.user_demo, - 'pricelist_id': self.pricelist_sale, + 'user_id': self.user_demo.id, + 'pricelist_id': self.pricelist_sale.id, } line = { - 'product_id': self.product_7, + 'product_id': self.product_32.id, + 'description': "[HEAD] Headset standard", 'requested_qty': 100, - 'requested_uom_id': self.product_uom_pce, + 'requested_uom_id': self.product_uom_pce.id, 'date_delivery': time.strftime(D_FMT), } source = { 'proposed_qty': 100, - 'proposed_product_id': self.product_7, - 'proposed_uom_id': self.product_uom_pce, - 'transport_applicable': 0, + 'proposed_product_id': self.product_32.id, + 'proposed_uom_id': self.product_uom_pce.id, 'procurement_method': 'procurement', 'price_is': 'estimated', } - self.requisition_id = logistic_requisition.create(self, vals) - self.line_id = logistic_requisition.add_line(self, self.requisition_id, - line) - self.source_id = logistic_requisition.add_source(self, self.line_id, - source) - logistic_requisition.confirm(self, self.requisition_id) - logistic_requisition.assign_lines(self, [self.line_id], self.user_demo) - purch_req_id = logistic_requisition.create_purchase_requisition( - self, self.source_id) - purchase_requisition.confirm_call(self, purch_req_id) - purch_req_model = self.registry('purchase.requisition') - self.purchase_requisition = purch_req_model.browse( - cr, uid, purch_req_id) - dp_obj = self.registry('decimal.precision') - self.uom_precision = dp_obj.precision_get(cr, SUPERUSER_ID, - 'Product Unit of Measure') + self.requisition = self.log_req.create(vals) + self.line = logistic_requisition.add_line(self, self.requisition, + line) + self.source = logistic_requisition.add_source(self, self.line, + source) + self.requisition.button_confirm() + logistic_requisition.assign_lines(self, self.line, self.user_demo.id) + purch_req = logistic_requisition.create_purchase_requisition( + self, self.source) + purchase_requisition.confirm_call(self, purch_req) + self.purchase_requisition = purch_req + dp_obj = self.env['decimal.precision'] + self.uom_precision = (dp_obj + .sudo() + .precision_get('Product Unit of Measure')) def test_split_too_many_products_selected_budget_exceeded(self): """ Create a call for bids from the logistic requisition, 2 po line @@ -122,25 +119,25 @@ def test_split_too_many_products_selected_budget_exceeded(self): We should not be able to propose more than requested financially. """ # create a first draft bid and select a part of the line - po_draft = purchase_requisition.create_draft_purchase_order( - self, self.purchase_requisition.id, self.partner_1) - purchase1, bid_line1 = po_draft - bid_line1.write({'price_unit': 15}) - purchase_order.select_line(self, bid_line1.id, 30) - purchase_order.bid_encoded(self, purchase1.id) + draft_po = purchase_requisition.create_draft_purchase_order( + self, self.purchase_requisition, self.partner_1.id) + purchase1, bid_line1 = draft_po + bid_line1.price_unit = 15 + purchase_order.select_line(self, bid_line1, 30) + purchase_order.bid_encoded(self, purchase1) # create a second draft bid and select a part of the line - po_draft = purchase_requisition.create_draft_purchase_order( - self, self.purchase_requisition.id, self.partner_12) - purchase2, bid_line2 = po_draft - bid_line2.write({'price_unit': 13}) - purchase_order.select_line(self, bid_line2.id, 80) - purchase_order.bid_encoded(self, purchase2.id) + draft_po = purchase_requisition.create_draft_purchase_order( + self, self.purchase_requisition, self.partner_12.id) + purchase2, bid_line2 = draft_po + bid_line2.price_unit = 13 + purchase_order.select_line(self, bid_line2, 80) + purchase_order.bid_encoded(self, purchase2) # close the call for bids - purchase_requisition.close_call(self, self.purchase_requisition.id) + purchase_requisition.close_call(self, self.purchase_requisition) # selection of bids will trigger the split of lines # the generation of po fails because the budget is exceeded - with self.assertRaises(orm.except_orm): + with self.assertRaises(exceptions.ValidationError): purchase_requisition.bids_selected(self, - self.purchase_requisition.id) + self.purchase_requisition) From bac9393d0917af463b7ff8d66f84b52dc88c5b63 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Fri, 31 Oct 2014 15:54:44 +0100 Subject: [PATCH 9/9] temporary disable a test due to odoo/#3422 --- logistic_budget/__openerp__.py | 2 ++ .../tests/test_purchase_split_requisition.py | 14 ++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/logistic_budget/__openerp__.py b/logistic_budget/__openerp__.py index f9ab7649..17f6ad28 100644 --- a/logistic_budget/__openerp__.py +++ b/logistic_budget/__openerp__.py @@ -45,6 +45,8 @@ "view/report_logistic_requisition.xml", ], "auto_install": False, + # TODO one test is disabled due to a bug with field functions odoo#3422 + # to reactivate once fixed "test": ['test/requisition_create_cost_estimate.yml', ], 'installable': True, diff --git a/logistic_budget/tests/test_purchase_split_requisition.py b/logistic_budget/tests/test_purchase_split_requisition.py index 7f67010b..7f6de340 100644 --- a/logistic_budget/tests/test_purchase_split_requisition.py +++ b/logistic_budget/tests/test_purchase_split_requisition.py @@ -22,8 +22,8 @@ import time from openerp.tools import DEFAULT_SERVER_DATE_FORMAT as D_FMT -from openerp import exceptions import openerp.tests.common as common +# from openerp import exceptions from openerp.addons.logistic_requisition.tests import logistic_requisition from openerp.addons.logistic_requisition.tests import purchase_requisition from openerp.addons.logistic_requisition.tests import purchase_order @@ -102,10 +102,6 @@ def setUp(self): self, self.source) purchase_requisition.confirm_call(self, purch_req) self.purchase_requisition = purch_req - dp_obj = self.env['decimal.precision'] - self.uom_precision = (dp_obj - .sudo() - .precision_get('Product Unit of Measure')) def test_split_too_many_products_selected_budget_exceeded(self): """ Create a call for bids from the logistic requisition, 2 po line @@ -138,6 +134,8 @@ def test_split_too_many_products_selected_budget_exceeded(self): purchase_requisition.close_call(self, self.purchase_requisition) # selection of bids will trigger the split of lines # the generation of po fails because the budget is exceeded - with self.assertRaises(exceptions.ValidationError): - purchase_requisition.bids_selected(self, - self.purchase_requisition) + # XXX + # disabled due to a bug with field functions odoo#3422 + # with self.assertRaises(exceptions.ValidationError): + # purchase_requisition.bids_selected(self, + # self.purchase_requisition)