From e56e5263930e58d111ec1b5e811b6550b2be5f11 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 18 Jul 2011 16:11:57 +0200 Subject: [PATCH 01/32] [FIX] account: corrected reports: - a many2many is _inherited; this means the relation table points to the original model, not to the actual model used in the wizard. This patch redefines explicitely the many2many in each _inheriting model. - In action_account_pl_report, target_move default is False. The test provides a value (this is a required field). bzr revid: vmt@openerp.com-20110718141157-aicd8mry14aj36yp --- .../account_analytic_cost_ledger_for_journal_report.py | 2 +- addons/account/test/account_report.yml | 4 ++-- addons/account/wizard/account_report_account_balance.py | 6 +++++- .../account/wizard/account_report_aged_partner_balance.py | 1 + addons/account/wizard/account_report_balance_sheet.py | 1 + addons/account/wizard/account_report_central_journal.py | 6 +++++- addons/account/wizard/account_report_general_journal.py | 8 ++++++-- addons/account/wizard/account_report_general_ledger.py | 1 + addons/account/wizard/account_report_partner_balance.py | 3 ++- addons/account/wizard/account_report_partner_ledger.py | 1 + addons/account/wizard/account_report_print_journal.py | 3 ++- addons/account/wizard/account_report_profit_loss.py | 2 ++ 12 files changed, 29 insertions(+), 9 deletions(-) diff --git a/addons/account/project/wizard/account_analytic_cost_ledger_for_journal_report.py b/addons/account/project/wizard/account_analytic_cost_ledger_for_journal_report.py index 93208532e45..186d39c4859 100644 --- a/addons/account/project/wizard/account_analytic_cost_ledger_for_journal_report.py +++ b/addons/account/project/wizard/account_analytic_cost_ledger_for_journal_report.py @@ -29,7 +29,7 @@ class account_analytic_cost_ledger_journal_report(osv.osv_memory): _columns = { 'date1': fields.date('Start of period', required=True), 'date2': fields.date('End of period', required=True), - 'journal': fields.many2many('account.analytic.journal', 'ledger_journal_rel', 'ledger_id', 'Journal_id', 'Journals'), + 'journal': fields.many2many('account.analytic.journal', 'ledger_journal_rel', 'ledger_id', 'journal_id', 'Journals'), } _defaults = { diff --git a/addons/account/test/account_report.yml b/addons/account/test/account_report.yml index d5bb6bada65..40ba7ea7127 100644 --- a/addons/account/test/account_report.yml +++ b/addons/account/test/account_report.yml @@ -147,7 +147,7 @@ !python {model: account.account}: | ctx={} ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')]}) - data_dict = {'chart_account_id':ref('account.chart0'),'display_type': False} + data_dict = {'chart_account_id':ref('account.chart0'),'display_type': False,'target_move': 'all'} from tools import test_reports test_reports.try_report_action(cr, uid, 'action_account_pl_report',wiz_data=data_dict, context=ctx, our_module='account') - @@ -156,7 +156,7 @@ !python {model: account.account}: | ctx={} ctx.update({'model': 'account.account','active_ids':[ref('account.chart0')]}) - data_dict = {'chart_account_id':ref('account.chart0'),'display_type': True} + data_dict = {'chart_account_id':ref('account.chart0'),'display_type': True,'target_move': 'all'} from tools import test_reports test_reports.try_report_action(cr, uid, 'action_account_pl_report',wiz_data=data_dict, context=ctx, our_module='account') - diff --git a/addons/account/wizard/account_report_account_balance.py b/addons/account/wizard/account_report_account_balance.py index a72d58dd904..4e52066b49e 100644 --- a/addons/account/wizard/account_report_account_balance.py +++ b/addons/account/wizard/account_report_account_balance.py @@ -19,13 +19,17 @@ # ############################################################################## -from osv import osv +from osv import osv, fields class account_balance_report(osv.osv_memory): _inherit = "account.common.account.report" _name = 'account.balance.report' _description = 'Trial Balance Report' + _columns = { + 'journal_ids': fields.many2many('account.journal', 'account_balance_report_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), + } + _defaults = { 'journal_ids': [], } diff --git a/addons/account/wizard/account_report_aged_partner_balance.py b/addons/account/wizard/account_report_aged_partner_balance.py index 4e6c6dea752..9b89b30c93b 100644 --- a/addons/account/wizard/account_report_aged_partner_balance.py +++ b/addons/account/wizard/account_report_aged_partner_balance.py @@ -35,6 +35,7 @@ class account_aged_trial_balance(osv.osv_memory): 'direction_selection': fields.selection([('past','Past'), ('future','Future')], 'Analysis Direction', required=True), + 'journal_ids': fields.many2many('account.journal', 'account_aged_trial_balance_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), } _defaults = { 'period_length': 30, diff --git a/addons/account/wizard/account_report_balance_sheet.py b/addons/account/wizard/account_report_balance_sheet.py index 873ede3832c..c8d2cf51870 100644 --- a/addons/account/wizard/account_report_balance_sheet.py +++ b/addons/account/wizard/account_report_balance_sheet.py @@ -45,6 +45,7 @@ class account_bs_report(osv.osv_memory): '(Profit: Amount will be added, Loss: Amount will be duducted), ' \ 'which is calculated from Profilt & Loss Report', domain = [('type','=','other')]), + 'journal_ids': fields.many2many('account.journal', 'account_bs_report_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), } _defaults={ diff --git a/addons/account/wizard/account_report_central_journal.py b/addons/account/wizard/account_report_central_journal.py index d66be0a70e4..eed21f976a5 100644 --- a/addons/account/wizard/account_report_central_journal.py +++ b/addons/account/wizard/account_report_central_journal.py @@ -19,13 +19,17 @@ # ############################################################################## -from osv import osv +from osv import osv, fields class account_central_journal(osv.osv_memory): _name = 'account.central.journal' _description = 'Account Central Journal' _inherit = "account.common.journal.report" + _columns = { + 'journal_ids': fields.many2many('account.journal', 'account_central_journal_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), + } + def _print_report(self, cr, uid, ids, data, context=None): data = self.pre_print_report(cr, uid, ids, data, context=context) return { diff --git a/addons/account/wizard/account_report_general_journal.py b/addons/account/wizard/account_report_general_journal.py index af091d9bc08..521c4667a80 100644 --- a/addons/account/wizard/account_report_general_journal.py +++ b/addons/account/wizard/account_report_general_journal.py @@ -19,17 +19,21 @@ # ############################################################################## -from osv import osv +from osv import osv, fields class account_general_journal(osv.osv_memory): _inherit = "account.common.journal.report" _name = 'account.general.journal' _description = 'Account General Journal' + _columns = { + 'journal_ids': fields.many2many('account.journal', 'account_general_journal_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), + } + def _print_report(self, cr, uid, ids, data, context=None): data = self.pre_print_report(cr, uid, ids, data, context=context) return {'type': 'ir.actions.report.xml', 'report_name': 'account.general.journal', 'datas': data} account_general_journal() -#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_general_ledger.py b/addons/account/wizard/account_report_general_ledger.py index ed75b3c1dce..d0b3c0fa3d3 100644 --- a/addons/account/wizard/account_report_general_ledger.py +++ b/addons/account/wizard/account_report_general_ledger.py @@ -32,6 +32,7 @@ class account_report_general_ledger(osv.osv_memory): help='If you selected to filter by date or period, this field allow you to add a row to display the amount of debit/credit/balance that precedes the filter you\'ve set.'), 'amount_currency': fields.boolean("With Currency", help="It adds the currency column if the currency is different then the company currency"), 'sortby': fields.selection([('sort_date', 'Date'), ('sort_journal_partner', 'Journal & Partner')], 'Sort by', required=True), + 'journal_ids': fields.many2many('account.journal', 'account_report_general_ledger_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), } _defaults = { 'landscape': True, diff --git a/addons/account/wizard/account_report_partner_balance.py b/addons/account/wizard/account_report_partner_balance.py index eff9e71cb72..80ee455456c 100644 --- a/addons/account/wizard/account_report_partner_balance.py +++ b/addons/account/wizard/account_report_partner_balance.py @@ -31,6 +31,7 @@ class account_partner_balance(osv.osv_memory): _columns = { 'display_partner': fields.selection([('non-zero_balance', 'With balance is not equal to 0'), ('all', 'All Partners')] ,'Display Partners'), + 'journal_ids': fields.many2many('account.journal', 'account_partner_balance_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), } _defaults = { @@ -51,4 +52,4 @@ class account_partner_balance(osv.osv_memory): account_partner_balance() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_partner_ledger.py b/addons/account/wizard/account_report_partner_ledger.py index 8a2b6c7bacb..7a3f3932f1b 100644 --- a/addons/account/wizard/account_report_partner_ledger.py +++ b/addons/account/wizard/account_report_partner_ledger.py @@ -35,6 +35,7 @@ class account_partner_ledger(osv.osv_memory): 'filter': fields.selection([('filter_no', 'No Filters'), ('filter_date', 'Date'), ('filter_period', 'Periods'), ('unreconciled', 'Unreconciled Entries')], "Filter by", required=True), 'page_split': fields.boolean('One Partner Per Page', help='Display Ledger Report with One partner per page'), 'amount_currency': fields.boolean("With Currency", help="It adds the currency column if the currency is different then the company currency"), + 'journal_ids': fields.many2many('account.journal', 'account_partner_ledger_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), } _defaults = { 'initial_balance': False, diff --git a/addons/account/wizard/account_report_print_journal.py b/addons/account/wizard/account_report_print_journal.py index f4a5fcaf9f9..d7e8f11a7f8 100644 --- a/addons/account/wizard/account_report_print_journal.py +++ b/addons/account/wizard/account_report_print_journal.py @@ -30,6 +30,7 @@ class account_print_journal(osv.osv_memory): 'sort_selection': fields.selection([('date', 'Date'), ('ref', 'Reference Number'),], 'Entries Sorted by', required=True), + 'journal_ids': fields.many2many('account.journal', 'account_print_journal_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), } _defaults = { 'sort_selection': 'date', @@ -44,4 +45,4 @@ class account_print_journal(osv.osv_memory): account_print_journal() -#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +#vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account/wizard/account_report_profit_loss.py b/addons/account/wizard/account_report_profit_loss.py index 6372539c056..301a7460e4d 100644 --- a/addons/account/wizard/account_report_profit_loss.py +++ b/addons/account/wizard/account_report_profit_loss.py @@ -28,8 +28,10 @@ class account_pl_report(osv.osv_memory): _inherit = "account.common.account.report" _name = "account.pl.report" _description = "Account Profit And Loss Report" + _columns = { 'display_type': fields.boolean("Landscape Mode"), + 'journal_ids': fields.many2many('account.journal', 'account_pl_report_journal_rel', 'account_id', 'journal_id', 'Journals', required=True), } _defaults = { From 99676d36810e7445f785ccd75b50b87275e3f890 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 18 Jul 2011 16:56:48 +0200 Subject: [PATCH 02/32] [FIX] sale: added stock.picking as active model in two tests. - this is needed if we want to use osv as a replacement for osv_memory because osv checks more carefully the selection fields. bzr revid: vmt@openerp.com-20110718145648-20lb8jo5s6pkw78m --- addons/sale/test/invoice_on_shipped_qty.yml | 2 +- addons/sale/test/picking_order_policy.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/sale/test/invoice_on_shipped_qty.yml b/addons/sale/test/invoice_on_shipped_qty.yml index bf2795e0f5b..c9acf4a63af 100644 --- a/addons/sale/test/invoice_on_shipped_qty.yml +++ b/addons/sale/test/invoice_on_shipped_qty.yml @@ -74,7 +74,7 @@ sale_id = sale_obj.browse(cr, uid, ref("sale_order_so6")) ids = [x.id for x in sale_id.picking_ids] wiz_id = self.create(cr, uid, {'invoice_date': time.strftime('%Y-%m-%d'), 'journal_id': ref('account.sales_journal')}, - {'active_ids': ids}) + {'active_ids': ids, 'active_model': 'stock.picking'}) self.create_invoice(cr, uid, [wiz_id], {"active_ids": ids, "active_id": ids[0]}) - I verify whether the invoice has been generated for SO diff --git a/addons/sale/test/picking_order_policy.yml b/addons/sale/test/picking_order_policy.yml index 4381c78f010..1aa8b893ccb 100644 --- a/addons/sale/test/picking_order_policy.yml +++ b/addons/sale/test/picking_order_policy.yml @@ -67,7 +67,7 @@ sale_id=sale_obj.browse(cr, uid, ref("sale_order_so7")) ids = [x.id for x in sale_id.picking_ids] wiz_id = self.create(cr, uid, {'invoice_date': time.strftime('%Y-%m-%d'), 'journal_id': ref('account.sales_journal')}, - {'active_ids': ids}) + {'active_ids': ids, 'active_model': 'stock.picking'}) self.create_invoice(cr, uid, [wiz_id], {"active_ids": ids, "active_id": ids[0]}) - I check that an invoice has been created. From 5feef07ecb359d2a07a1f60753b9b7c1c9bea248 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 18 Jul 2011 17:14:03 +0200 Subject: [PATCH 03/32] [FIX] purchase: added active_model: stock.picking to a test. bzr revid: vmt@openerp.com-20110718151403-afci1t50838p6o1s --- addons/purchase/test/purchase_from_picking.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/purchase/test/purchase_from_picking.yml b/addons/purchase/test/purchase_from_picking.yml index 94239ba28c4..e7b8b2b4fa4 100644 --- a/addons/purchase/test/purchase_from_picking.yml +++ b/addons/purchase/test/purchase_from_picking.yml @@ -137,7 +137,7 @@ pur_id1=pur_obj.browse(cr, uid, ref("purchase_order_po2")) pick_ids = [x.id for x in pur_id1.picking_ids] id = self.create(cr, uid, {'invoice_date': time.strftime('%Y-%m-%d'), 'journal_id': ref('account.expenses_journal')}, - {'active_ids': pick_ids}) + {'active_ids': pick_ids, 'active_model': 'stock.picking'}) self.create_invoice(cr, uid, [id], {"active_ids": pick_ids, "active_id": pick_ids[0]}) - I check that an invoice_ids field of Delivery&Invoices gets bind with the value. From f5273c1eb13bd5a9bc190c18c3c85f9fb06009a4 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Tue, 19 Jul 2011 11:28:39 +0200 Subject: [PATCH 04/32] [FIX] stock: corrected one2many/many2one so they match. - it was possible they didnt match because of osv_memory lack of foreign key constraint. - they have to match has we will get rid of osv_memory. bzr revid: vmt@openerp.com-20110719092839-z8wio48uib2sa1td --- addons/stock/wizard/stock_partial_move.py | 14 ++++------- addons/stock/wizard/stock_partial_picking.py | 26 +++++++++++++++++--- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/addons/stock/wizard/stock_partial_move.py b/addons/stock/wizard/stock_partial_move.py index 874b22844d1..1487dd193c4 100644 --- a/addons/stock/wizard/stock_partial_move.py +++ b/addons/stock/wizard/stock_partial_move.py @@ -25,22 +25,18 @@ import time class stock_partial_move_memory_out(osv.osv_memory): + _inherit = "stock.picking.memory.out" _name = "stock.move.memory.out" - _rec_name = 'product_id' _columns = { - 'product_id' : fields.many2one('product.product', string="Product", required=True), - 'quantity' : fields.float("Quantity", required=True), - 'product_uom': fields.many2one('product.uom', 'Unit of Measure', required=True), - 'prodlot_id' : fields.many2one('stock.production.lot', 'Production Lot'), - 'move_id' : fields.many2one('stock.move', "Move"), 'wizard_id' : fields.many2one('stock.partial.move', string="Wizard"), - 'cost' : fields.float("Cost", help="Unit Cost for this product line"), - 'currency' : fields.many2one('res.currency', string="Currency", help="Currency in which Unit cost is expressed"), } class stock_partial_move_memory_in(osv.osv_memory): - _inherit = "stock.move.memory.out" + _inherit = "stock.picking.memory.in" _name = "stock.move.memory.in" + _columns = { + 'wizard_id' : fields.many2one('stock.partial.move', string="Wizard"), + } class stock_partial_move(osv.osv_memory): _name = "stock.partial.move" diff --git a/addons/stock/wizard/stock_partial_picking.py b/addons/stock/wizard/stock_partial_picking.py index 421bcae10ba..04714b8914c 100644 --- a/addons/stock/wizard/stock_partial_picking.py +++ b/addons/stock/wizard/stock_partial_picking.py @@ -24,15 +24,33 @@ from osv import fields, osv from tools.translate import _ import time +class stock_partial_picking_memory_out(osv.osv_memory): + _name = "stock.picking.memory.out" + _rec_name = 'product_id' + _columns = { + 'product_id' : fields.many2one('product.product', string="Product", required=True), + 'quantity' : fields.float("Quantity", required=True), + 'product_uom': fields.many2one('product.uom', 'Unit of Measure', required=True), + 'prodlot_id' : fields.many2one('stock.production.lot', 'Production Lot'), + 'move_id' : fields.many2one('stock.move', "Move"), + 'wizard_id' : fields.many2one('stock.partial.picking', string="Wizard"), + 'cost' : fields.float("Cost", help="Unit Cost for this product line"), + 'currency' : fields.many2one('res.currency', string="Currency", help="Currency in which Unit cost is expressed"), + } + +class stock_partial_picking_memory_in(osv.osv_memory): + _inherit = "stock.picking.memory.out" + _name = "stock.picking.memory.in" + class stock_partial_picking(osv.osv_memory): _name = "stock.partial.picking" _description = "Partial Picking" _columns = { 'date': fields.datetime('Date', required=True), - 'product_moves_out' : fields.one2many('stock.move.memory.out', 'wizard_id', 'Moves'), - 'product_moves_in' : fields.one2many('stock.move.memory.in', 'wizard_id', 'Moves'), + 'product_moves_out' : fields.one2many('stock.picking.memory.out', 'wizard_id', 'Moves'), + 'product_moves_in' : fields.one2many('stock.picking.memory.in', 'wizard_id', 'Moves'), } - + def get_picking_type(self, cr, uid, picking, context=None): picking_type = picking.type for move in picking.move_lines: @@ -169,5 +187,7 @@ class stock_partial_picking(osv.osv_memory): return {'type': 'ir.actions.act_window_close'} stock_partial_picking() +stock_partial_picking_memory_out() +stock_partial_picking_memory_in() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 8109d17623906fb98af3deb5a2a74bcc40866a2d Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Tue, 19 Jul 2011 15:34:19 +0200 Subject: [PATCH 05/32] [FIX] l10n_be: commenting out a seemingly unused column. Need to make sure it has to disappear. bzr revid: vmt@openerp.com-20110719133419-x9utuzmpz9x22a8x --- addons/l10n_be/wizard/l10n_be_partner_vat_listing.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addons/l10n_be/wizard/l10n_be_partner_vat_listing.py b/addons/l10n_be/wizard/l10n_be_partner_vat_listing.py index 2ab26d66439..e43dbfecf2b 100644 --- a/addons/l10n_be/wizard/l10n_be_partner_vat_listing.py +++ b/addons/l10n_be/wizard/l10n_be_partner_vat_listing.py @@ -117,7 +117,8 @@ class partner_vat_list_13(osv.osv_memory): """ Partner Vat Listing """ _name = "partner.vat.list_13" _columns = { - 'partner_ids': fields.many2many('vat.listing.clients', 'vat_partner_rel', 'vat_id', 'partner_id', 'Clients', required=False, help='You can remove clients/partners which you do not want to show in xml file'), + # TODO the referenced model has been deleted at revno 4672.1.2. + #'partner_ids': fields.many2many('vat.listing.clients', 'vat_partner_rel', 'vat_id', 'partner_id', 'Clients', required=False, help='You can remove clients/partners which you do not want to show in xml file'), 'name': fields.char('File Name', size=32), 'msg': fields.text('File created', size=64, readonly=True), 'file_save' : fields.binary('Save File', readonly=True), @@ -127,7 +128,8 @@ class partner_vat_list_13(osv.osv_memory): return context.get('partner_ids', []) _defaults={ - 'partner_ids': _get_partners + # TODO the referenced model has been deleted at revno 4672.1.2. + # 'partner_ids': _get_partners } def create_xml(self, cursor, user, ids, context=None): From 55f4e24c663aa27dbbc3465486813d662deea561 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Tue, 19 Jul 2011 16:08:32 +0200 Subject: [PATCH 06/32] [FIX] sale: size kwarg in float field seems to be in fact a digits kwarg. bzr revid: vmt@openerp.com-20110719140832-hzta4p9t5vfjwp5b --- addons/sale/wizard/sale_make_invoice_advance.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/sale/wizard/sale_make_invoice_advance.py b/addons/sale/wizard/sale_make_invoice_advance.py index 4b1e4511021..4d9e0058e94 100644 --- a/addons/sale/wizard/sale_make_invoice_advance.py +++ b/addons/sale/wizard/sale_make_invoice_advance.py @@ -27,8 +27,8 @@ class sale_advance_payment_inv(osv.osv_memory): _columns = { 'product_id': fields.many2one('product.product', 'Advance Product', required=True, help="Select a product of type service which is called 'Advance Product'. You may have to create it and set it as a default value on this field."), - 'amount': fields.float('Advance Amount', size=(16, 2), required=True, help="The amount to be invoiced in advance."), - 'qtty': fields.float('Quantity', size=(16, 2), required=True), + 'amount': fields.float('Advance Amount', digits=(16, 2), required=True, help="The amount to be invoiced in advance."), + 'qtty': fields.float('Quantity', digits=(16, 2), required=True), } _defaults = { 'qtty': 1.0 @@ -173,4 +173,4 @@ class sale_open_invoice(osv.osv_memory): sale_open_invoice() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From 68244bf4042c30a89772cc11d0084b53c5bf8cb5 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Wed, 27 Jul 2011 17:23:15 +0200 Subject: [PATCH 07/32] [FIX] pos test: a selection field is stored as a string but used as an int. bzr revid: vmt@openerp.com-20110727152315-kl2mi6dglmbdztq8 --- addons/point_of_sale/point_of_sale.py | 4 ++-- addons/point_of_sale/test/point_of_sale_report.yml | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/point_of_sale/point_of_sale.py b/addons/point_of_sale/point_of_sale.py index 31c580ba506..b57d383c2d5 100644 --- a/addons/point_of_sale/point_of_sale.py +++ b/addons/point_of_sale/point_of_sale.py @@ -553,7 +553,7 @@ class pos_order(osv.osv): args['ref'] = order.contract_number or None statement_id = statement_obj.search(cr,uid, [ - ('journal_id', '=', data['journal']), + ('journal_id', '=', int(data['journal'])), ('company_id', '=', curr_company), ('user_id', '=', uid), ('state', '=', 'open')], context=context) @@ -563,7 +563,7 @@ class pos_order(osv.osv): statement_id = statement_id[0] args['statement_id'] = statement_id args['pos_statement_id'] = order_id - args['journal_id'] = data['journal'] + args['journal_id'] = int(data['journal']) args['type'] = 'customer' args['ref'] = order.name statement_line_obj.create(cr, uid, args, context=context) diff --git a/addons/point_of_sale/test/point_of_sale_report.yml b/addons/point_of_sale/test/point_of_sale_report.yml index b821dc899df..ead21be6a36 100644 --- a/addons/point_of_sale/test/point_of_sale_report.yml +++ b/addons/point_of_sale/test/point_of_sale_report.yml @@ -52,6 +52,11 @@ if tools.config['test_report_directory']: file(os.path.join(tools.config['test_report_directory'], 'point_of_sale-receipt without reimbursement report'+format), 'wb+').write(data) +- + Create a record for the root user in pos.payment.report.user (used by the next python block). +- + !record {model: pos.payment.report.user, id: pos_payment_report_user_1}: + user_id: [] - Print the POS Payment Report through the wizard - From 847ddda54082f52a1e4a8f81ec4a4d64409c4bcf Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Tue, 16 Aug 2011 12:32:48 +0200 Subject: [PATCH 08/32] [FIX] changed super(osv,self) to super(the-model,self). bzr revid: vmt@openerp.com-20110816103248-ufdcbkwh2u6c05u7 --- addons/account/account.py | 2 +- addons/account/account_move_line.py | 2 +- addons/account_analytic_plans/account_analytic_plans.py | 4 ++-- addons/crm/crm.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/addons/account/account.py b/addons/account/account.py index 0cee9291e97..37d31dcdbe3 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -1242,7 +1242,7 @@ class account_move(osv.osv): context = {} c = context.copy() c['novalidate'] = True - result = super(osv.osv, self).write(cr, uid, ids, vals, c) + result = super(account_move, self).write(cr, uid, ids, vals, c) self.validate(cr, uid, ids, context=context) return result diff --git a/addons/account/account_move_line.py b/addons/account/account_move_line.py index 06a3d8c44e9..5a4447ba872 100644 --- a/addons/account/account_move_line.py +++ b/addons/account/account_move_line.py @@ -1296,7 +1296,7 @@ class account_move_line(osv.osv): 'user_id': uid })] - result = super(osv.osv, self).create(cr, uid, vals, context=context) + result = super(account_move_line, self).create(cr, uid, vals, context=context) # CREATE Taxes if vals.get('account_tax_id', False): tax_id = tax_obj.browse(cr, uid, vals['account_tax_id']) diff --git a/addons/account_analytic_plans/account_analytic_plans.py b/addons/account_analytic_plans/account_analytic_plans.py index c8ab5334d8a..c62e6ea98d0 100644 --- a/addons/account_analytic_plans/account_analytic_plans.py +++ b/addons/account_analytic_plans/account_analytic_plans.py @@ -366,7 +366,7 @@ class account_move_line(osv.osv): def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): if context is None: context = {} - result = super(osv.osv, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) + result = super(account_move_line, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar=toolbar, submenu=submenu) return result account_move_line() @@ -496,4 +496,4 @@ class account_bank_statement_line(osv.osv): } account_bank_statement_line() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/crm/crm.py b/addons/crm/crm.py index f6d3964cf0b..4d23f827e7a 100644 --- a/addons/crm/crm.py +++ b/addons/crm/crm.py @@ -300,7 +300,7 @@ class crm_case(crm_base): default.update({ 'date_open': False }) - return super(osv.osv, self).copy(cr, uid, id, default, context=context) + return super(crm_case, self).copy(cr, uid, id, default, context=context) From fcd415ceee85572e5e3aa2a57514faaa3cd67dde Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Wed, 17 Aug 2011 10:43:05 +0200 Subject: [PATCH 09/32] [FIX] anonymization: size (in a field kwargs) is an int, not a string. bzr revid: vmt@openerp.com-20110817084305-nk5cpfn338r1nsxj --- addons/anonymization/anonymization.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/anonymization/anonymization.py b/addons/anonymization/anonymization.py index c4a2d9f0488..834ce576c17 100644 --- a/addons/anonymization/anonymization.py +++ b/addons/anonymization/anonymization.py @@ -239,7 +239,7 @@ class ir_model_fields_anonymize_wizard(osv.osv_memory): return res _columns = { - 'name': fields.char(size='64', string='File Name'), + 'name': fields.char(size=64, string='File Name'), 'summary': fields.function(_get_summary, type='text', string='Summary'), 'file_export': fields.binary(string='Export'), 'file_import': fields.binary(string='Import'), From a3252963a571c0c64a5b98fd7d2d9fd4e89085a1 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Tue, 23 Aug 2011 14:46:01 +0200 Subject: [PATCH 10/32] [FIX] idea: correct selection field values (i.e. strings). bzr revid: vmt@openerp.com-20110823124601-5em26jbf4459t0f5 --- addons/idea/test/test_idea.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/idea/test/test_idea.yml b/addons/idea/test/test_idea.yml index 402f93f4817..4ce9d706e69 100644 --- a/addons/idea/test/test_idea.yml +++ b/addons/idea/test/test_idea.yml @@ -56,7 +56,7 @@ - !python {model: idea.post.vote}: | uid2 = ref('test_idea_user1') - new_id = self.create(cr, uid2, {'vote': 50}, {"active_ids": [ref("idea_idea_0")]}) + new_id = self.create(cr, uid2, {'vote': "50"}, {"active_ids": [ref("idea_idea_0")]}) self.do_vote(cr, uid2, [new_id], {"active_ids": [ref("idea_idea_0")]}) - | @@ -69,7 +69,7 @@ - !python {model: idea.post.vote}: | uid2 = ref('test_idea_user2') - new_id = self.create(cr, uid2, {'vote': 100, 'note': 'We can learn many things from technical presentation'}, {"active_ids": [ref("idea_idea_0")]}) + new_id = self.create(cr, uid2, {'vote': "100", 'note': 'We can learn many things from technical presentation'}, {"active_ids": [ref("idea_idea_0")]}) self.do_vote(cr, uid2, [new_id], {'active_ids': [ref('idea_idea_0')]}) - | From b657bea06f94a22e6370601571e77f913e329a92 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Wed, 24 Aug 2011 11:35:27 +0200 Subject: [PATCH 11/32] [FIX] survey: correctly cast selection fields to int, properly use a relation table for many2many fields. bzr revid: vmt@openerp.com-20110824093527-e8u4d410zof48vpm --- addons/survey/wizard/survey_answer.py | 5 +++-- addons/survey/wizard/survey_print.py | 2 +- addons/survey/wizard/survey_print_statistics.py | 2 +- addons/survey/wizard/survey_selection.py | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/addons/survey/wizard/survey_answer.py b/addons/survey/wizard/survey_answer.py index 896bde70d3c..140e934af87 100644 --- a/addons/survey/wizard/survey_answer.py +++ b/addons/survey/wizard/survey_answer.py @@ -600,8 +600,9 @@ class survey_question_wiz(osv.osv_memory): if not sur_name_read['store_ans']: his_id = self.pool.get('survey.history').create(cr, uid, {'user_id': uid, \ 'date': strftime('%Y-%m-%d %H:%M:%S'), 'survey_id': sur_name_read['survey_id']}) - sur_rec = survey_obj.read(cr, uid, sur_name_read['survey_id']) - survey_obj.write(cr, uid, sur_name_read['survey_id'], {'tot_start_survey' : sur_rec['tot_start_survey'] + 1}) + survey_id = int(sur_name_read['survey_id']) # This is a selection field (a string). + sur_rec = survey_obj.read(cr, uid, survey_id) + survey_obj.write(cr, uid, survey_id, {'tot_start_survey' : sur_rec['tot_start_survey'] + 1}) if context.has_key('cur_id'): if context.has_key('request') and context.get('request',False): self.pool.get(context.get('object',False)).write(cr, uid, [int(context.get('cur_id',False))], {'response' : response_id}) diff --git a/addons/survey/wizard/survey_print.py b/addons/survey/wizard/survey_print.py index 87767f34a68..4592bd38b6e 100644 --- a/addons/survey/wizard/survey_print.py +++ b/addons/survey/wizard/survey_print.py @@ -27,7 +27,7 @@ from tools.translate import _ class survey_print(osv.osv_memory): _name = 'survey.print' _columns = { - 'survey_ids': fields.many2many('survey','survey_print',\ + 'survey_ids': fields.many2many('survey','survey_print_survey_rel',\ 'survey_id','print_id', "Survey", required="1"), 'orientation' : fields.selection([('vertical','Portrait(Vertical)'),\ ('horizontal','Landscape(Horizontal)')], 'Orientation'), diff --git a/addons/survey/wizard/survey_print_statistics.py b/addons/survey/wizard/survey_print_statistics.py index 10b321fcf45..57a05910966 100644 --- a/addons/survey/wizard/survey_print_statistics.py +++ b/addons/survey/wizard/survey_print_statistics.py @@ -26,7 +26,7 @@ from tools.translate import _ class survey_print_statistics(osv.osv_memory): _name = 'survey.print.statistics' _columns = { - 'survey_ids': fields.many2many('survey','survey_print_statistics','survey_id',\ + 'survey_ids': fields.many2many('survey','survey_print_statistics_survey_rel','survey_id',\ 'print_id', "Survey", required="1"), } diff --git a/addons/survey/wizard/survey_selection.py b/addons/survey/wizard/survey_selection.py index 8d613c74bd0..0809254b8a7 100644 --- a/addons/survey/wizard/survey_selection.py +++ b/addons/survey/wizard/survey_selection.py @@ -64,7 +64,7 @@ class survey_name_wiz(osv.osv_memory): survey_user_group_id = self.pool.get('res.groups').search(cr, uid, [('name', '=', 'Survey / User')]) group_id = self.pool.get('res.groups').search(cr, uid, [('name', 'in', ('Tools / Manager','Tools / User','Survey / User'))]) user_obj = self.pool.get('res.users') - user_rec = user_obj.read(cr, uid, uid) + user_rec = user_obj.read(cr, uid, uid, ['groups_id', 'survey_id'], context) if survey_user_group_id: if survey_user_group_id == user_rec['groups_id']: for sur in surv_obj.browse(cr, uid, surv_obj.search(cr, uid, [])): @@ -123,7 +123,7 @@ class survey_name_wiz(osv.osv_memory): if context is None: context = {} this = self.browse(cr, uid, ids, context=context)[0] - survey_id = this.survey_id + survey_id = int(this.survey_id) # This is a selection field (a string). context.update({'survey_id': survey_id, 'sur_name_id': this.id}) cr.execute('select count(id) from survey_history where user_id=%s\ and survey_id=%s' % (uid,survey_id)) From 0c102a578cc9995ba4d2b727b1ac906656d42eca Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Wed, 24 Aug 2011 14:19:13 +0200 Subject: [PATCH 12/32] [FIX] outlook: fields.char size kwarg is an integer. bzr revid: vmt@openerp.com-20110824121913-bso674ol4uvkh347 --- addons/outlook/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/outlook/installer.py b/addons/outlook/installer.py index 4d0ac1e1971..2be0c243037 100644 --- a/addons/outlook/installer.py +++ b/addons/outlook/installer.py @@ -41,7 +41,7 @@ class outlook_installer(osv.osv_memory): 'doc_name':fields.char('File name', size=64), 'outlook':fields.boolean('Outlook Plug-in ', help="Allows you to select an object that you would like to add to your email and its attachments."), 'plugin_file':fields.binary('Outlook Plug-in', readonly=True, help="outlook plug-in file. Save as this file and install this plug-in in outlook."), - 'doc_file':fields.char('Installation Manual',size="264",help="The documentation file :- how to install Outlook Plug-in.", readonly=True), + 'doc_file':fields.char('Installation Manual',size=264,help="The documentation file :- how to install Outlook Plug-in.", readonly=True), 'description':fields.text('Description', readonly=True) } From c978be0052846478d7bdb5d0b8a1bbebb483dbbb Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Wed, 24 Aug 2011 14:59:49 +0200 Subject: [PATCH 13/32] [FIX] thunderbird: fields.char size kwarg is an integer. bzr revid: vmt@openerp.com-20110824125949-9flddp034glld69u --- addons/thunderbird/installer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/thunderbird/installer.py b/addons/thunderbird/installer.py index 5bf11218842..35d31b9d636 100644 --- a/addons/thunderbird/installer.py +++ b/addons/thunderbird/installer.py @@ -41,7 +41,7 @@ class thunderbird_installer(osv.osv_memory): 'pdf_name':fields.char('File name', size=64), 'thunderbird':fields.boolean('Thunderbird Plug-in', help="Allows you to select an object that you would like to add to your email and its attachments."), 'plugin_file':fields.binary('Thunderbird Plug-in', readonly=True, help="Thunderbird plug-in file. Save as this file and install this plug-in in thunderbird."), - 'pdf_file':fields.char('Installation Manual', size="264", help="The documentation file :- how to install Thunderbird Plug-in.", readonly=True), + 'pdf_file':fields.char('Installation Manual', size=264, help="The documentation file :- how to install Thunderbird Plug-in.", readonly=True), 'description':fields.text('Description', readonly=True) } From e28b8e56ba0c3df3acb930685a3d6a450961bfb1 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 25 Aug 2011 11:35:10 +0200 Subject: [PATCH 14/32] [FIX] crm_partner_assign: added a required state in a test. bzr revid: vmt@openerp.com-20110825093510-omqublx7hxzbvg5d --- addons/crm_partner_assign/test/test_crm_partner_assign.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/crm_partner_assign/test/test_crm_partner_assign.yml b/addons/crm_partner_assign/test/test_crm_partner_assign.yml index 202c96c3555..b2c1db4f40d 100644 --- a/addons/crm_partner_assign/test/test_crm_partner_assign.yml +++ b/addons/crm_partner_assign/test/test_crm_partner_assign.yml @@ -65,7 +65,8 @@ 'name': 'email', 'email_to': 'info@axelor.com', 'email_from': 'Administrator ', - 'reply_to': 'sales_openerp@openerp.com' + 'reply_to': 'sales_openerp@openerp.com', + 'state': 'draft', } ids = self.create(cr, uid, vals, context={'active_id': ref('crm_lead_questionnaireonopenerp0'), 'active_model': 'crm.lead'}) assert tools.config.get('smtp_user', False), 'SMTP not configured !' From d5aab62e582a0575ca4fb5ec446b9556630ea7e4 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Fri, 26 Aug 2011 12:13:45 +0200 Subject: [PATCH 15/32] [FIX] hr_attendance: correctly use an int instead of a char to store an id (even use a many2one). bzr revid: vmt@openerp.com-20110826101345-7lk6w909lpvyca3l --- addons/hr_attendance/wizard/hr_attendance_sign_in_out.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py index 7a51c2b9e1e..2631139b38d 100644 --- a/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py +++ b/addons/hr_attendance/wizard/hr_attendance_sign_in_out.py @@ -29,7 +29,7 @@ class hr_si_so_ask(osv.osv_memory): _columns = { 'name': fields.char('Employees name', size=32, required=True, readonly=True), 'last_time': fields.datetime('Your last sign out', required=True), - 'emp_id': fields.char('Empoyee ID', size=32, required=True, readonly=True), + 'emp_id': fields.many2one('hr.employee', 'Empoyee ID', readonly=True), } def _get_empname(self, cr, uid, context=None): @@ -52,10 +52,12 @@ class hr_si_so_ask(osv.osv_memory): def sign_in(self, cr, uid, ids, context=None): data = self.read(cr, uid, ids, [], context=context)[0] + data['emp_id'] = data['emp_id'] and data['emp_id'][0] return self.pool.get('hr.sign.in.out').sign_in(cr, uid, data, context) def sign_out(self, cr, uid, ids, context=None): data = self.read(cr, uid, ids, [], context=context)[0] + data['emp_id'] = data['emp_id'] and data['emp_id'][0] return self.pool.get('hr.sign.in.out').sign_out(cr, uid, data, context) hr_si_so_ask() @@ -68,7 +70,7 @@ class hr_sign_in_out(osv.osv_memory): _columns = { 'name': fields.char('Employees name', size=32, required=True, readonly=True), 'state': fields.char('Current state', size=32, required=True, readonly=True), - 'emp_id': fields.char('Employee ID', size=32, required=True, readonly=True), + 'emp_id': fields.many2one('hr.employee', 'Empoyee ID', readonly=True), } def _get_empid(self, cr, uid, context=None): @@ -88,6 +90,7 @@ class hr_sign_in_out(osv.osv_memory): obj_model = self.pool.get('ir.model.data') att_obj = self.pool.get('hr.attendance') data = self.read(cr, uid, ids, [], context=context)[0] + data['emp_id'] = data['emp_id'] and data['emp_id'][0] emp_id = data['emp_id'] att_id = att_obj.search(cr, uid, [('employee_id', '=', emp_id)], limit=1, order='name desc') last_att = att_obj.browse(cr, uid, att_id, context=context) @@ -113,6 +116,7 @@ class hr_sign_in_out(osv.osv_memory): obj_model = self.pool.get('ir.model.data') att_obj = self.pool.get('hr.attendance') data = self.read(cr, uid, ids, [], context=context)[0] + data['emp_id'] = data['emp_id'] and data['emp_id'][0] emp_id = data['emp_id'] att_id = att_obj.search(cr, uid, [('employee_id', '=', emp_id),('action', '!=', 'action')], limit=1, order='name desc') last_att = att_obj.browse(cr, uid, att_id, context=context) From 04fefe363e3d052001b775b01c957b60573e4a2d Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 29 Aug 2011 11:46:34 +0200 Subject: [PATCH 16/32] [FIX] crm_profiling: use osv.osv instead of orm.orm for super(), account_followup: use the newly added option on many2many to prevent the creation of foreign key constraints on the relation table. bzr revid: vmt@openerp.com-20110829094634-kmef4wk17q6rzya8 --- addons/account_followup/wizard/account_followup_print.py | 2 +- addons/crm_profiling/crm_profiling.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py index 18b0fc1b874..ec598ca7a46 100644 --- a/addons/account_followup/wizard/account_followup_print.py +++ b/addons/account_followup/wizard/account_followup_print.py @@ -115,7 +115,7 @@ class account_followup_print_all(osv.osv_memory): _name = 'account.followup.print.all' _description = 'Print Followup & Send Mail to Customers' _columns = { - 'partner_ids': fields.many2many('account_followup.stat.by.partner', 'partner_stat_rel', 'osv_memory_id', 'partner_id', 'Partners', required=True, domain="[('account_id.type', '=', 'receivable'), ('account_id.reconcile', '=', True), ('reconcile_id','=', False), ('state', '!=', 'draft'), ('account_id.active', '=', True), ('debit', '>', 0)]"), + 'partner_ids': fields.many2many('account_followup.stat.by.partner', 'partner_stat_rel', 'osv_memory_id', 'partner_id', 'Partners', required=True, domain="[('account_id.type', '=', 'receivable'), ('account_id.reconcile', '=', True), ('reconcile_id','=', False), ('state', '!=', 'draft'), ('account_id.active', '=', True), ('debit', '>', 0)]", no_foreign_keys=True), 'email_conf': fields.boolean('Send email confirmation'), 'email_subject': fields.char('Email Subject', size=64), 'partner_lang': fields.boolean('Send Email in Partner Language', help='Do not change message text, if you want to send email in partner language, or configure from company'), diff --git a/addons/crm_profiling/crm_profiling.py b/addons/crm_profiling/crm_profiling.py index 90dc0818743..59137966da0 100644 --- a/addons/crm_profiling/crm_profiling.py +++ b/addons/crm_profiling/crm_profiling.py @@ -264,7 +264,7 @@ class crm_segmentation(osv.osv): } _constraints = [ - (orm.orm._check_recursion, 'Error ! You can not create recursive profiles.', ['parent_id']) + (osv.osv._check_recursion, 'Error ! You can not create recursive profiles.', ['parent_id']) ] def process_continue(self, cr, uid, ids, start=False): From 036af85fd202c20190b5ea73e58d280aa601a98c Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 29 Aug 2011 14:16:44 +0200 Subject: [PATCH 17/32] [FIX] stock_planning: add a many2one corresponding to a one2many. Perhaps it should be replaced by a many2many to keep the table schema clean. bzr revid: vmt@openerp.com-20110829121644-2uwuy9p5328z3pml --- addons/stock_planning/stock_planning.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/stock_planning/stock_planning.py b/addons/stock_planning/stock_planning.py index 7e9342292b9..35337b28bdf 100644 --- a/addons/stock_planning/stock_planning.py +++ b/addons/stock_planning/stock_planning.py @@ -41,7 +41,8 @@ class stock_period(osv.osv): 'name': fields.char('Period Name', size=64, required=True), 'date_start': fields.datetime('Start Date', required=True), 'date_stop': fields.datetime('End Date', required=True), - 'state': fields.selection([('draft','Draft'), ('open','Open'),('close','Close')], 'State') + 'state': fields.selection([('draft','Draft'), ('open','Open'),('close','Close')], 'State'), + 'planning_id': fields.many2one('stock.period.createlines', 'Stock Period Planning'), } _defaults = { 'state': 'draft' From 4eed2f442b1530950c780397f950bcd9bff99c91 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Mon, 29 Aug 2011 17:56:49 +0200 Subject: [PATCH 18/32] [FIX] stock_invoice_directly: use account.sales_journal instead of account.bank_journal seems to make a the test pass but actually this should be reviewed. bzr revid: vmt@openerp.com-20110829155649-3zzxzscat4d5yd3o --- addons/stock_invoice_directly/test/stock_invoice_directly.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/addons/stock_invoice_directly/test/stock_invoice_directly.yml b/addons/stock_invoice_directly/test/stock_invoice_directly.yml index 6d70540b4d5..eca6f388348 100644 --- a/addons/stock_invoice_directly/test/stock_invoice_directly.yml +++ b/addons/stock_invoice_directly/test/stock_invoice_directly.yml @@ -63,8 +63,8 @@ As the Invoice state of the picking order is To be invoiced. I create invoice for my outgoing picking order. - !python {model: stock.invoice.onshipping}: | - wiz_id = self.create(cr, uid, {'invoice_date': '2010-08-04', 'journal_id': ref('account.bank_journal')}, - {'active_ids': [ref("stock_picking_out0")]}) + wiz_id = self.create(cr, uid, {'invoice_date': '2010-08-04', 'journal_id': ref('account.sales_journal')}, + {'active_ids': [ref("stock_picking_out0")], "active_model": "stock.picking"}) self.create_invoice(cr, uid, [wiz_id], {"lang": "en_US", "search_default_available": 1, "tz": False, "active_model": "stock.picking", "contact_display": "partner", "active_ids": [ref("stock_picking_out0")], "active_id": ref("stock_picking_out0")}) From 1821512ebfefbed19c4ee2501ed5dcf557876017 Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Tue, 30 Aug 2011 11:24:53 +0200 Subject: [PATCH 19/32] [FIX] mrp tests: it seems the created partial picking row was not used (and 1 was hardcoded instead). bzr revid: vmt@openerp.com-20110830092453-ynbjx0725mxik1h0 --- addons/mrp/test/mrp_phantom_bom.yml | 2 +- addons/mrp/test/mrp_procurement.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mrp/test/mrp_phantom_bom.yml b/addons/mrp/test/mrp_phantom_bom.yml index 6bb297fbcfb..7a4747e038c 100644 --- a/addons/mrp/test/mrp_phantom_bom.yml +++ b/addons/mrp/test/mrp_phantom_bom.yml @@ -256,7 +256,7 @@ !python {model: stock.partial.picking}: | pick_obj = self.pool.get('stock.picking') picking_ids = pick_obj.search(cr, uid, [('type','=','in'),('state','=','assigned')]) - partial = self.browse(cr, uid, 1, context) + partial = self.browse(cr, uid, ref('stock_partial_picking0'), context) partial_datas = { 'delivery_date': partial.date } diff --git a/addons/mrp/test/mrp_procurement.yml b/addons/mrp/test/mrp_procurement.yml index 568a5f0b0e8..b716948770a 100644 --- a/addons/mrp/test/mrp_procurement.yml +++ b/addons/mrp/test/mrp_procurement.yml @@ -210,7 +210,7 @@ !python {model: stock.partial.picking}: | pick_obj = self.pool.get('stock.picking') picking_ids = pick_obj.search(cr, uid, [('address_id.name','=','Wong'),('state','=','assigned')]) - partial = self.browse(cr, uid, 1, context) + partial = self.browse(cr, uid, ref('stock_partial_picking0'), context) partial_datas = { 'delivery_date' : partial.date } @@ -246,7 +246,7 @@ !python {model: stock.partial.picking}: | pick_obj = self.pool.get('stock.picking') picking_ids = pick_obj.search(cr, uid, [('address_id.name','=','Tang'),('state','=','assigned')]) - partial = self.browse(cr, uid, 1, context) + partial = self.browse(cr, uid, ref('stock_partial_picking0'), context) partial_datas = { 'delivery_date': partial.date } From 5d152edf6d372b1f55e981bcf129aea515f6078b Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Thu, 22 Sep 2011 14:12:48 +0200 Subject: [PATCH 20/32] [IMP] stock_planning: use a many2many instead of one2many (from transient model to model). bzr revid: vmt@openerp.com-20110922121248-v6vzt0ncstp3obmf --- addons/stock_planning/stock_planning.py | 1 - addons/stock_planning/wizard/stock_planning_create_periods.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/stock_planning/stock_planning.py b/addons/stock_planning/stock_planning.py index 35337b28bdf..8d267892eda 100644 --- a/addons/stock_planning/stock_planning.py +++ b/addons/stock_planning/stock_planning.py @@ -42,7 +42,6 @@ class stock_period(osv.osv): 'date_start': fields.datetime('Start Date', required=True), 'date_stop': fields.datetime('End Date', required=True), 'state': fields.selection([('draft','Draft'), ('open','Open'),('close','Close')], 'State'), - 'planning_id': fields.many2one('stock.period.createlines', 'Stock Period Planning'), } _defaults = { 'state': 'draft' diff --git a/addons/stock_planning/wizard/stock_planning_create_periods.py b/addons/stock_planning/wizard/stock_planning_create_periods.py index 7d4012453de..75231faaa28 100644 --- a/addons/stock_planning/wizard/stock_planning_create_periods.py +++ b/addons/stock_planning/wizard/stock_planning_create_periods.py @@ -46,6 +46,7 @@ class stock_period_createlines(osv.osv_memory): 'date_start': fields.date('Start Date', required=True, help="Starting date for planning period."), 'date_stop': fields.date('End Date', required=True, help="Ending date for planning period."), 'period_ids': fields.one2many('stock.period', 'planning_id', 'Periods'), + 'period_ids': fields.many2many('stock.period', 'stock_period_createlines_stock_period_rel', 'wizard_id', 'period_id', 'Periods'), } _defaults={ 'date_start': _get_new_period_start, From 7723574f635dd8158896169af905eb29a9ca8b3d Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Fri, 23 Sep 2011 18:27:56 +0200 Subject: [PATCH 21/32] [IMP] account_followup: removed invalid domain + remove no_foreign_keys (deprecated) bzr revid: odo@openerp.com-20110923162756-g87xjb22isheq6bi --- addons/account_followup/wizard/account_followup_print.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/addons/account_followup/wizard/account_followup_print.py b/addons/account_followup/wizard/account_followup_print.py index b5ea0596b51..d0cd9650193 100644 --- a/addons/account_followup/wizard/account_followup_print.py +++ b/addons/account_followup/wizard/account_followup_print.py @@ -115,7 +115,8 @@ class account_followup_print_all(osv.osv_memory): _name = 'account.followup.print.all' _description = 'Print Followup & Send Mail to Customers' _columns = { - 'partner_ids': fields.many2many('account_followup.stat.by.partner', 'partner_stat_rel', 'osv_memory_id', 'partner_id', 'Partners', required=True, domain="[('account_id.type', '=', 'receivable'), ('account_id.reconcile', '=', True), ('reconcile_id','=', False), ('state', '!=', 'draft'), ('account_id.active', '=', True), ('debit', '>', 0)]", no_foreign_keys=True), + 'partner_ids': fields.many2many('account_followup.stat.by.partner', 'partner_stat_rel', 'osv_memory_id', 'partner_id', + 'Partners', required=True), 'email_conf': fields.boolean('Send email confirmation'), 'email_subject': fields.char('Email Subject', size=64), 'partner_lang': fields.boolean('Send Email in Partner Language', help='Do not change message text, if you want to send email in partner language, or configure from company'), From 39c648126e7a067f01edae8a5b7846c1131932ac Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Sun, 25 Sep 2011 03:47:59 +0200 Subject: [PATCH 22/32] [FIX] mail.compose.message: do not override with undefined defaults bzr revid: odo@openerp.com-20110925014759-g3ycy8fgmv1zgg9x --- addons/mail/wizard/mail_compose_message.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/addons/mail/wizard/mail_compose_message.py b/addons/mail/wizard/mail_compose_message.py index 0bfaf06890a..93bf0b004d8 100644 --- a/addons/mail/wizard/mail_compose_message.py +++ b/addons/mail/wizard/mail_compose_message.py @@ -82,9 +82,9 @@ class mail_compose_message(osv.osv_memory): else: # default mode result['model'] = context.get('active_model', False) - if vals: - for field in fields: - result.update({field : vals.get(field, False)}) + for field in vals: + if field in fields: + result.update({field : vals[field]}) # link to model and record if not done yet if not result.get('model') or not result.get('res_id'): From 3b1196867b9e26afd81bd4adc42e4882e53400b7 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Sun, 25 Sep 2011 03:48:42 +0200 Subject: [PATCH 23/32] [FIX] crm_partner_assign: remove obsolete field from view bzr revid: odo@openerp.com-20110925014842-d3rx8nhgizgmv8sp --- addons/crm_partner_assign/wizard/crm_forward_to_partner_view.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/crm_partner_assign/wizard/crm_forward_to_partner_view.xml b/addons/crm_partner_assign/wizard/crm_forward_to_partner_view.xml index d3ecddb1aa3..8bdb03cf962 100644 --- a/addons/crm_partner_assign/wizard/crm_forward_to_partner_view.xml +++ b/addons/crm_partner_assign/wizard/crm_forward_to_partner_view.xml @@ -25,7 +25,6 @@ - From e45e0b75d8623895ff47da62b04110a04ea548ea Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Mon, 26 Sep 2011 02:36:12 +0200 Subject: [PATCH 24/32] [IMP] stock: cleanup stock.partial.{picking,move} wizards and fix dependencies and tests bzr revid: odo@openerp.com-20110926003612-0wa6sghmlwbezwzk --- addons/mrp/test/mrp_phantom_bom.yml | 60 +---- addons/mrp/test/mrp_procurement.yml | 80 ++---- addons/purchase/stock.py | 67 +---- addons/sale/test/invoice_on_ordered_qty.yml | 36 +-- addons/sale/test/invoice_on_shipped_qty.yml | 46 +--- addons/sale/test/manual_order_policy.yml | 95 ++----- addons/sale/test/picking_order_policy.yml | 82 ++---- addons/sale/test/postpaid_order_policy.yml | 73 ++---- addons/sale/test/prepaid_order_policy.yml | 69 ++--- addons/stock/stock.py | 16 +- addons/stock/test/stock_test.yml | 19 +- addons/stock/wizard/stock_partial_move.py | 233 ++++------------- .../stock/wizard/stock_partial_move_view.xml | 120 ++++----- addons/stock/wizard/stock_partial_picking.py | 243 ++++++------------ .../wizard/stock_partial_picking_view.xml | 54 ++++ .../test/stock_invoice_directly.yml | 23 +- .../wizard/stock_invoice.py | 25 +- 17 files changed, 391 insertions(+), 950 deletions(-) diff --git a/addons/mrp/test/mrp_phantom_bom.yml b/addons/mrp/test/mrp_phantom_bom.yml index 7a4747e038c..1f499a5fb7f 100644 --- a/addons/mrp/test/mrp_phantom_bom.yml +++ b/addons/mrp/test/mrp_phantom_bom.yml @@ -205,9 +205,8 @@ I am checking Procurement orders. There are 3 orders generated for Oranges, Sugar and Water. - !python {model: procurement.order}: | - from tools.translate import _ proc_ids = self.search(cr, uid, [('product_id','in',[ref('product_product_orange0'),ref('product_product_sugar0'),ref('product_product_water0')])]) - assert proc_ids, _('No Procurements!') + assert proc_ids, 'No Procurements!' - The scheduler runs. - @@ -219,9 +218,8 @@ stock moves for Oranges, Sugar and Water made correctly. - !python {model: stock.picking}: | - from tools.translate import _ pick_ids = self.search(cr, uid, [('type','=','internal')]) - assert pick_ids, _('No Internal Pickings!') + assert pick_ids, 'No Internal Pickings!' - According to minimum stock rules. I have 2 purchase orders for Sugar with 6 Kg from Axelor and Orange 60 Kg from ASUStek. @@ -229,50 +227,24 @@ I confirm the purchase order of Sugar and Orange. - !python {model: purchase.order}: | - from tools.translate import _ import netsvc purch_ids = self.search(cr, uid, [('state','=','draft')]) - assert purch_ids, _('No Purchase Orders were made!') + assert purch_ids, 'No Purchase Orders were made!' wf_service = netsvc.LocalService("workflow") for p_id in purch_ids: wf_service.trg_validate(uid, 'purchase.order', p_id, 'purchase_confirm', cr) - - I see two incoming pickings for Orange and Sugar. + I see two incoming pickings for Orange and Sugar, and receive them. - !python {model: stock.picking}: | - from tools.translate import _ pick_ids = self.search(cr, uid, [('type','=','in')]) - assert pick_ids, _('No Incoming Shipments found!') -- - I receive both the products. My incoming pickings are done. -- - I create record for the incoming picking wizard. -- - !record {model: stock.partial.picking, id: stock_partial_picking0}: - date: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S") -- - I make my pickings done. -- - !python {model: stock.partial.picking}: | - pick_obj = self.pool.get('stock.picking') - picking_ids = pick_obj.search(cr, uid, [('type','=','in'),('state','=','assigned')]) - partial = self.browse(cr, uid, ref('stock_partial_picking0'), context) - partial_datas = { - 'delivery_date': partial.date - } - for pick in pick_obj.browse(cr, uid, picking_ids): - for m in pick.move_lines: - partial_datas['move%s'%(m.id)] = { - 'product_id': m.product_id.id, - 'product_qty': m.product_qty, - 'product_uom': m.product_uom.id - } - if (pick.type == 'in') and (m.product_id.cost_method == 'average'): - partial_datas['move%s'%(m.id)].update({ - 'product_price': m.product_price, - 'product_currency': m.product_currency - }) - pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context) + assert pick_ids, 'No Incoming Shipments found!' + stock_partial_picking = self.pool.get('stock.partial.picking') + for pick_id in pick_ids: + partial_id = stock_partial_picking.create(cr, uid, {}, + context={'active_model': 'stock.picking', + 'active_ids': [pick_id]}) + stock_partial_picking.do_partial(cr, uid, [partial_id]) - Again the scheduler runs. - @@ -283,19 +255,15 @@ I check my internal picking of "Orange Juice" is done. - !python {model: stock.picking}: | - from tools.translate import _ pick_ids = self.search(cr, uid, [('type','=','internal'),('state','=','done')]) - assert pick_ids, _('Internal Picking is not done yet!') + assert pick_ids, 'Internal Picking is not done yet!' - I check my manufacturing order for "Orange Juice" is ready or not. - !python {model: mrp.production}: | - from tools.translate import _ - pick_ids = self.search(cr, uid, [('state','=','ready'),('id','=',ref('mrp_production_mo0'))]) - assert pick_ids, _('Manufacturing order is not ready!') + prod_ids = self.search(cr, uid, [('state','=','ready'),('id','=',ref('mrp_production_mo0'))]) + assert prod_ids, 'Manufacturing order is not ready!' - I start the production order. - !workflow {model: mrp.production, action: button_produce, ref: mrp_production_mo0} - - diff --git a/addons/mrp/test/mrp_procurement.yml b/addons/mrp/test/mrp_procurement.yml index b716948770a..4aaf1560432 100644 --- a/addons/mrp/test/mrp_procurement.yml +++ b/addons/mrp/test/mrp_procurement.yml @@ -195,74 +195,26 @@ I Check incoming shipments for cloth. And receive products. - !python {model: stock.picking}: | - from tools.translate import _ pick_ids = self.search(cr, uid, [('address_id.name','=','Wong'),('state','=','assigned')]) - assert pick_ids, _('No Incoming Shipments found!') -- - I create record for partial picking. -- - !record {model: stock.partial.picking, id: stock_partial_picking0}: - date: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S") - -- - I make my picking done. -- - !python {model: stock.partial.picking}: | - pick_obj = self.pool.get('stock.picking') - picking_ids = pick_obj.search(cr, uid, [('address_id.name','=','Wong'),('state','=','assigned')]) - partial = self.browse(cr, uid, ref('stock_partial_picking0'), context) - partial_datas = { - 'delivery_date' : partial.date - } - for pick in pick_obj.browse(cr, uid, picking_ids): - for m in pick.move_lines: - partial_datas['move%s'%(m.id)] = { - 'product_id' : m.product_id.id, - 'product_qty' : m.product_qty, - 'product_uom' : m.product_uom.id - } - if (pick.type == 'in') and (m.product_id.cost_method == 'average'): - partial_datas['move%s'%(m.id)].update({ - 'product_price' : m.product_price, - 'product_currency': m.product_currency - }) - pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context) + assert pick_ids, 'No Incoming Shipments found!' + stock_partial_picking = self.pool.get('stock.partial.picking') + for pick_id in pick_ids: + partial_id = stock_partial_picking.create(cr, uid, {}, + context={'active_model': 'stock.picking', + 'active_ids': [pick_id]}) + stock_partial_picking.do_partial(cr, uid, [partial_id]) - I Check incoming shipments for buttons and receive products. - !python {model: stock.picking}: | - from tools.translate import _ pick_ids = self.search(cr, uid, [('address_id.name','=','Tang'),('state','=','assigned')]) - assert pick_ids, _('No Incoming Shipments found!') -- - I create record for partial picking. -- - !record {model: stock.partial.picking, id: stock_partial_picking0}: - date: !eval datetime.today().strftime("%Y-%m-%d %H:%M:%S") - -- - I make my picking done. -- - !python {model: stock.partial.picking}: | - pick_obj = self.pool.get('stock.picking') - picking_ids = pick_obj.search(cr, uid, [('address_id.name','=','Tang'),('state','=','assigned')]) - partial = self.browse(cr, uid, ref('stock_partial_picking0'), context) - partial_datas = { - 'delivery_date': partial.date - } - for pick in pick_obj.browse(cr, uid, picking_ids): - for m in pick.move_lines: - partial_datas['move%s'%(m.id)] = { - 'product_id': m.product_id.id, - 'product_qty': m.product_qty, - 'product_uom': m.product_uom.id - } - if (pick.type == 'in') and (m.product_id.cost_method == 'average'): - partial_datas['move%s'%(m.id)].update({ - 'product_price': m.product_price, - 'product_currency': m.product_currency - }) - pick_obj.do_partial(cr, uid, picking_ids, partial_datas, context=context) + assert pick_ids, 'No Incoming Shipments found!' + stock_partial_picking = self.pool.get('stock.partial.picking') + for pick_id in pick_ids: + partial_id = stock_partial_picking.create(cr, uid, {}, + context={'active_model': 'stock.picking', + 'active_ids': [pick_id]}) + stock_partial_picking.do_partial(cr, uid, [partial_id]) - Run scheduler again. - @@ -297,7 +249,6 @@ I produce 2 products with 5.00 quantities each. - !python {model: mrp.product.produce}: | - from tools.translate import _ prod_obj = self.pool.get('mrp.production') prod_ids = prod_obj.search(cr, uid, [('product_id.name','=','Shirt')]) self.do_produce(cr, uid, [ref('mrp_product_produce0')], context={'active_ids': prod_ids}) @@ -321,8 +272,7 @@ And finally production order is done. - !python {model: mrp.product.produce}: | - from tools.translate import _ prod_obj = self.pool.get('mrp.production') prod_ids = prod_obj.search(cr, uid, [('product_id.name','=','Shirt')]) - self.do_produce(cr, uid, [1], context={'active_ids': prod_ids}) + self.do_produce(cr, uid, [ref('mrp_product_produce0')], context={'active_ids': prod_ids}) diff --git a/addons/purchase/stock.py b/addons/purchase/stock.py index 696c4d708fe..29b4aa29318 100644 --- a/addons/purchase/stock.py +++ b/addons/purchase/stock.py @@ -124,68 +124,15 @@ class stock_picking(osv.osv): purchase_obj.write(cursor, user, [picking.purchase_id.id], {'invoice_id': invoice_id,}) return super(stock_picking, self)._invoice_hook(cursor, user, picking, invoice_id) -stock_picking() - class stock_partial_picking(osv.osv_memory): _inherit = 'stock.partial.picking' - def default_get(self, cr, uid, fields, context=None): - """ To get default values for the object. - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param fields: List of fields for which we want default values - @param context: A standard dictionary - @return: A dictionary which of fields with values. - """ - if context is None: - context = {} - pick_obj = self.pool.get('stock.picking') - res = super(stock_partial_picking, self).default_get(cr, uid, fields, context=context) - for pick in pick_obj.browse(cr, uid, context.get('active_ids', []), context=context): - has_product_cost = (pick.type == 'in' and pick.purchase_id) - for m in pick.move_lines: - if m.state in ('done','cancel') : - continue - if has_product_cost and m.product_id.cost_method == 'average' and m.purchase_line_id: - # We use the original PO unit purchase price as the basis for the cost, expressed - # in the currency of the PO (i.e the PO's pricelist currency) - list_index = 0 - for item in res['product_moves_in']: - if item['move_id'] == m.id: - res['product_moves_in'][list_index]['cost'] = m.purchase_line_id.price_unit - res['product_moves_in'][list_index]['currency'] = m.picking_id.purchase_id.pricelist_id.currency_id.id - list_index += 1 - return res -stock_partial_picking() + # Overridden to inject the purchase price as true 'cost price' when processing + # incoming pickings. + def _product_cost_for_average_update(self, cr, uid, move): + if move.picking_id.purchase_id: + return {'cost': move.purchase_line_id.price_unit, + 'currency': move.picking_id.purchase_id.pricelist_id.currency_id.id} + return super(stock_partial_picking, self)._product_cost_for_average_update(cr, uid, move) -class stock_partial_move(osv.osv_memory): - _inherit = "stock.partial.move" - def default_get(self, cr, uid, fields, context=None): - """ To get default values for the object. - @param self: The object pointer. - @param cr: A database cursor - @param uid: ID of the user currently logged in - @param fields: List of fields for which we want default values - @param context: A standard dictionary - @return: A dictionary which of fields with values. - """ - if context is None: - context = {} - res = super(stock_partial_move, self).default_get(cr, uid, fields, context=context) - move_obj = self.pool.get('stock.move') - for m in move_obj.browse(cr, uid, context.get('active_ids', []), context=context): - if m.picking_id.type == 'in' and m.product_id.cost_method == 'average' \ - and m.purchase_line_id and m.picking_id.purchase_id: - # We use the original PO unit purchase price as the basis for the cost, expressed - # in the currency of the PO (i.e the PO's pricelist currency) - list_index = 0 - for item in res['product_moves_in']: - if item['move_id'] == m.id: - res['product_moves_in'][list_index]['cost'] = m.purchase_line_id.price_unit - res['product_moves_in'][list_index]['currency'] = m.picking_id.purchase_id.pricelist_id.currency_id.id - list_index += 1 - return res -stock_partial_move() # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: - diff --git a/addons/sale/test/invoice_on_ordered_qty.yml b/addons/sale/test/invoice_on_ordered_qty.yml index 785b2d8835e..313aa3a0d63 100644 --- a/addons/sale/test/invoice_on_ordered_qty.yml +++ b/addons/sale/test/invoice_on_ordered_qty.yml @@ -31,39 +31,17 @@ - !workflow {model: sale.order, action: order_confirm, ref: sale_order_so9} - - I verify that the picking has been generated for the sale order + I verify that the picking has been generated for the sale order and I process it - !python {model: sale.order}: | so = self.browse(cr, uid, ref("sale_order_so9")) assert so.picking_ids,"Picking has not been generated for sale_order_so9" -- - Then I confirm the picking -- - !record {model: stock.partial.picking, id: stock_partial_picking_0}: - date: !eval time.strftime('%Y-%m-%d %H:%M:%S') -- - Then I done the picking -- - !python {model: stock.picking }: | - import time - sale_order_obj = self.pool.get('sale.order') - so = sale_order_obj.browse(cr, uid, ref("sale_order_so9")) - picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')]) - if picking_id: - pick=self.browse(cr,uid,picking_id[0]) - pick.force_assign(cr, uid) - partial_datas = { - 'partner_id':pick.address_id.partner_id.id, - 'address_id': pick.address_id.id, - 'delivery_date' : time.strftime('%Y-%m-%d'), - } - move = pick.move_lines[0] - partial_datas['move%s'%(move.id)]= { - 'product_id': move.product_id.id, - 'product_qty': '100', - 'product_uom': move.product_uom.id, - } - self.do_partial(cr, uid, [pick.id],partial_datas) + picking, = so.picking_ids + stock_partial_picking = self.pool.get('stock.partial.picking') + partial_id = stock_partial_picking.create(cr, uid, {}, + context={'active_model': 'stock.picking', + 'active_ids': [picking.id]}) + stock_partial_picking.do_partial(cr, uid, [partial_id]) - I click on Create Invoice button to create the invoice. - diff --git a/addons/sale/test/invoice_on_shipped_qty.yml b/addons/sale/test/invoice_on_shipped_qty.yml index c9acf4a63af..c6ac86471be 100644 --- a/addons/sale/test/invoice_on_shipped_qty.yml +++ b/addons/sale/test/invoice_on_shipped_qty.yml @@ -30,41 +30,21 @@ - !workflow {model: sale.order, action: order_confirm, ref: sale_order_so6} - - I verify that the picking has been generated for the sale order + I verify that the picking has been generated for the sale order and I process it - !python {model: sale.order}: | so = self.browse(cr, uid, ref("sale_order_so6")) assert so.picking_ids,"Picking has not been generated for sale_order_so6" -- - Then I click on the "Product Sent" button of Outgoing Shipments -- - !record {model: stock.partial.picking, id: stock_partial_picking_0}: - date: !eval time.strftime('%Y-%m-%d %H:%M:%S') -- - I change the quantity on the picking to 199, and confirm partially 100 PCE. -- - !python {model: stock.picking }: | - import time - sale_order_obj = self.pool.get('sale.order') - so = sale_order_obj.browse(cr, uid, ref("sale_order_so6")) - picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')]) - if picking_id: - pick=self.browse(cr,uid,picking_id[0]) - self.pool.get('stock.move').write(cr, uid, [pick.move_lines[0].id], {'product_qty': 199, 'product_uos_qty': 199}) - pick=self.browse(cr,uid,picking_id[0]) - pick.force_assign(cr, uid) - partial_datas = { - 'partner_id':pick.address_id.partner_id.id, - 'address_id': pick.address_id.id, - 'delivery_date' : time.strftime('%Y-%m-%d'), - } - move = pick.move_lines[0] - partial_datas['move%s'%(move.id)]= { - 'product_id': move.product_id.id, - 'product_qty': '100', - 'product_uom': move.product_uom.id, - } - self.do_partial(cr, uid, [pick.id],partial_datas) + picking, = so.picking_ids + stock_partial_picking = self.pool.get('stock.partial.picking') + partial_id = stock_partial_picking.create(cr, uid, {}, + context={'active_model': 'stock.picking', + 'active_ids': [picking.id]}) + # I change the qty to 100 for a partial delivery + partial = stock_partial_picking.browse(cr,uid,partial_id) + line_id = partial.move_ids[0].id + partial.write({'move_ids': [(1,line_id,{'quantity':100})]}) + partial.do_partial() - Then I click on 'Create Invoices' button - @@ -72,7 +52,7 @@ import time sale_obj = self.pool.get('sale.order') sale_id = sale_obj.browse(cr, uid, ref("sale_order_so6")) - ids = [x.id for x in sale_id.picking_ids] + ids = [x.id for x in sale_id.picking_ids if x.state == 'done'] wiz_id = self.create(cr, uid, {'invoice_date': time.strftime('%Y-%m-%d'), 'journal_id': ref('account.sales_journal')}, {'active_ids': ids, 'active_model': 'stock.picking'}) self.create_invoice(cr, uid, [wiz_id], {"active_ids": ids, "active_id": ids[0]}) @@ -98,7 +78,7 @@ inv_brw = self.browse(cr,uid,inv_id)[0] for inv_lines in inv_brw.invoice_line: qty1=inv_lines.quantity - assert (qty1 == qty), "Quantities are not the same" + assert (qty1 == qty), "Quantities are not the same: invoiced: %s, shipped: %s" % (qty1,qty) - I open the Invoice for the SO. - diff --git a/addons/sale/test/manual_order_policy.yml b/addons/sale/test/manual_order_policy.yml index c1535402f9b..35f38e8b23d 100644 --- a/addons/sale/test/manual_order_policy.yml +++ b/addons/sale/test/manual_order_policy.yml @@ -136,15 +136,10 @@ I verify that a procurement state is "running" - !python {model: procurement.order}: | - from tools.translate import _ - modules = self.pool.get('ir.module.module') - mod_pur = modules.search(cr, uid, [('name','=','purchase')]) - mod_brw = modules.browse(cr,uid,mod_pur)[0] - if (mod_brw.state == 'installed'): - sale_order_obj = self.pool.get('sale.order') - so = sale_order_obj.browse(cr, uid, ref("sale_order_so0")) - proc_ids = self.search(cr, uid, [('origin','=',so.name),('state','=','running')]) - assert(proc_ids),"Procurement is not in the running state!" + sale_order_obj = self.pool.get('sale.order') + so = sale_order_obj.browse(cr, uid, ref("sale_order_so0")) + proc_ids = self.search(cr, uid, [('origin','=',so.name),('state','=','running')]) + assert(proc_ids),"Procurement is not in the running state!" - I verify that a purchase order has been generated - @@ -192,7 +187,7 @@ for pur in pur_ids: wf_service.trg_validate(uid, 'purchase.order',pur,'purchase_approve', cr) - - I verify that a picking related to purchase order has been generated. + I verify that a picking related to purchase order has been generated and I process it - !python {model: sale.order}: | modules = self.pool.get('ir.module.module') @@ -204,29 +199,12 @@ pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)]) po = pur_obj.browse(cr, uid, pur_id)[0] assert(po.picking_ids),"Picking for purchase order has not been generated" -- - Then I click on the "Products Received" button of Incoming Shipments -- - !record {model: stock.partial.picking, id: stock_partial_picking_0}: - date: !eval time.strftime('%Y-%m-%d %H:%M:%S') -- - I click on the "Validate" button -- - !python {model: stock.picking}: | - modules = self.pool.get('ir.module.module') - sale_order_obj = self.pool.get('sale.order') - pur_obj = self.pool.get('purchase.order') - mod_pur = modules.search(cr, uid, [('name','=','purchase')]) - mod_brw = modules.browse(cr,uid,mod_pur)[0] - if (mod_brw.state == 'installed'): - so = sale_order_obj.browse(cr, uid, ref("sale_order_so0")) - pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)]) - po = pur_obj.browse(cr, uid, pur_id)[0] - pick_ser_id = self.search(cr, uid, [('purchase_id', '=', po.id )]) - import netsvc - wf_service = netsvc.LocalService("workflow") - for pick in pick_ser_id: - wf_service.trg_validate(uid, 'stock.picking',pick,'button_done', cr) + picking, = po.picking_ids + stock_partial_picking = self.pool.get('stock.partial.picking') + partial_id = stock_partial_picking.create(cr, uid, {}, + context={'active_model': 'stock.picking', + 'active_ids': [picking.id]}) + stock_partial_picking.do_partial(cr, uid, [partial_id]) - I verify that picking for purchase order has been done. - @@ -244,7 +222,7 @@ ids = picking_obj.search(cr, uid, [('purchase_id', '=', po.id ),('state', '=', 'done')]) assert(ids),"Picking is not in the done state!" - - Then I done the picking + Then I process the picking - !python {model: stock.picking }: | import time @@ -254,18 +232,11 @@ if picking_id: pick=self.browse(cr,uid,picking_id[0]) pick.force_assign(cr, uid) - partial_datas = { - 'partner_id':pick.address_id.partner_id.id, - 'address_id': pick.address_id.id, - 'delivery_date' : time.strftime('%Y-%m-%d'), - } - move = pick.move_lines[0] - partial_datas['move%s'%(move.id)]= { - 'product_id': move.product_id.id, - 'product_qty': move.product_qty, - 'product_uom': move.product_uom.id, - } - self.do_partial(cr, uid, [pick.id],partial_datas) + stock_partial_picking = self.pool.get('stock.partial.picking') + partial_id = stock_partial_picking.create(cr, uid, {}, + context={'active_model': 'stock.picking', + 'active_ids': [pick.id]}) + stock_partial_picking.do_partial(cr, uid, [partial_id]) - I verify that picking for sale order is in done state. - @@ -275,38 +246,6 @@ picking_id = self.search(cr, uid, [('origin','=',so.name),('type','=','out')]) pick = self.browse(cr,uid,picking_id[0]) assert (pick.state) =='done', "Picking for SO is not in done state." -- - Then I done the delivery order -- - !python {model: stock.picking }: | - import time - sale_order_obj = self.pool.get('sale.order') - so = sale_order_obj.browse(cr, uid, ref("sale_order_so0")) - picking_id = self.search(cr, uid, [('origin','=',so.name)]) - if picking_id: - pick=self.browse(cr,uid,picking_id[0]) - pick.force_assign(cr, uid) - partial_datas = { - 'partner_id':pick.address_id.partner_id.id, - 'address_id': pick.address_id.id, - 'delivery_date' : time.strftime('%Y-%m-%d'), - } - move = pick.move_lines[0] - partial_datas['move%s'%(move.id)]= { - 'product_id': move.product_id.id, - 'product_qty': move.product_qty, - 'product_uom': move.product_uom.id, - } - self.do_partial(cr, uid, [pick.id],partial_datas) -- - I verify that delivery state is done -- - !python {model: stock.picking }: | - sale_order_obj = self.pool.get('sale.order') - so = sale_order_obj.browse(cr, uid, ref("sale_order_so0")) - picking_id = self.search(cr, uid, [('origin','=',so.name)]) - pick = self.browse(cr,uid,picking_id[0]) - assert (pick.state) =='done', "Picking for SO is not in done state." - I verify that a "Picked" has been set to true - diff --git a/addons/sale/test/picking_order_policy.yml b/addons/sale/test/picking_order_policy.yml index 1aa8b893ccb..1dcbf980da4 100644 --- a/addons/sale/test/picking_order_policy.yml +++ b/addons/sale/test/picking_order_policy.yml @@ -46,18 +46,11 @@ if picking_id: pick=self.browse(cr,uid,picking_id[0]) pick.force_assign(cr, uid) - partial_datas = { - 'partner_id':pick.address_id.partner_id.id, - 'address_id': pick.address_id.id, - 'delivery_date' : time.strftime('%Y-%m-%d'), - } - move = pick.move_lines[0] - partial_datas['move%s'%(move.id)]= { - 'product_id': move.product_id.id, - 'product_qty': move.product_qty, - 'product_uom': move.product_uom.id, - } - self.do_partial(cr, uid, [pick.id],partial_datas) + stock_partial_picking = self.pool.get('stock.partial.picking') + partial_id = stock_partial_picking.create(cr, uid, {}, + context={'active_model': 'stock.picking', + 'active_ids': [pick.id]}) + stock_partial_picking.do_partial(cr, uid, [partial_id]) - Then I click on 'Create Invoices' button - @@ -197,7 +190,7 @@ for pur in pur_ids: wf_service.trg_validate(uid, 'purchase.order',pur,'purchase_approve', cr) - - I verify that a picking related to purchase order has been generated. + I verify that a picking related to purchase order has been generated and I process it - !python {model: sale.order}: | modules = self.pool.get('ir.module.module') @@ -209,29 +202,12 @@ pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)]) po = pur_obj.browse(cr, uid, pur_id)[0] assert(po.picking_ids),"Picking for purchase order has not been generated" -- - Then I click on the "Products Received" button of Incoming Shipments -- - !record {model: stock.partial.picking, id: stock_partial_picking_0}: - date: !eval time.strftime('%Y-%m-%d %H:%M:%S') -- - I click on the "Validate" button -- - !python {model: stock.picking}: | - modules = self.pool.get('ir.module.module') - mod_pur = modules.search(cr, uid, [('name','=','purchase')]) - mod_brw = modules.browse(cr,uid,mod_pur)[0] - if (mod_brw.state == 'installed'): - sale_order_obj = self.pool.get('sale.order') - pur_obj = self.pool.get('purchase.order') - so = sale_order_obj.browse(cr, uid, ref("sale_order_so7")) - pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)]) - po = pur_obj.browse(cr, uid, pur_id)[0] - pick_ser_id = self.search(cr, uid, [('purchase_id', '=', po.id )]) - import netsvc - wf_service = netsvc.LocalService("workflow") - for pick in pick_ser_id: - wf_service.trg_validate(uid, 'stock.picking',pick,'button_done', cr) + picking, = po.picking_ids + stock_partial_picking = self.pool.get('stock.partial.picking') + partial_id = stock_partial_picking.create(cr, uid, {}, + context={'active_model': 'stock.picking', + 'active_ids': [picking.id]}) + stock_partial_picking.do_partial(cr, uid, [partial_id]) - I verify that picking for purchase order has been done. - @@ -249,36 +225,20 @@ ids = picking_obj.search(cr, uid, [('purchase_id', '=', po.id ),('state', '=', 'done')]) assert ids, _('Picking is not in the done state!') - - I verify that delivery order has been generated for sale order + I verify that delivery order has been generated for sale order, and process it - !python {model: stock.picking }: | sale_order_obj = self.pool.get('sale.order') so = sale_order_obj.browse(cr, uid, ref("sale_order_so7")) picking_id = self.search(cr, uid, [('origin','=',so.name)]) assert (picking_id),"Delivery order has not been generated" -- - I verify that delivery has been done -- - !python {model: stock.picking }: | - import time - sale_order_obj = self.pool.get('sale.order') - so = sale_order_obj.browse(cr, uid, ref("sale_order_so7")) - picking_id = self.search(cr, uid, [('origin','=',so.name)]) - if picking_id: - pick=self.browse(cr,uid,picking_id[0]) - pick.force_assign(cr, uid) - partial_datas = { - 'partner_id':pick.address_id.partner_id.id, - 'address_id': pick.address_id.id, - 'delivery_date' : time.strftime('%Y-%m-%d'), - } - move = pick.move_lines[0] - partial_datas['move%s'%(move.id)]= { - 'product_id': move.product_id.id, - 'product_qty': move.product_qty, - 'product_uom': move.product_uom.id, - } - self.do_partial(cr, uid, [pick.id],partial_datas) + pick=self.browse(cr,uid,picking_id[0]) + pick.force_assign(cr, uid) + stock_partial_picking = self.pool.get('stock.partial.picking') + partial_id = stock_partial_picking.create(cr, uid, {}, + context={'active_model': 'stock.picking', + 'active_ids': [pick.id]}) + stock_partial_picking.do_partial(cr, uid, [partial_id]) - I verify that delivery state is done - @@ -290,7 +250,7 @@ pick = self.browse(cr,uid,picking_id[0]) assert (pick.state) =='done', "Picking for SO is not in done state." - - I verify that a "Picked" has been set to true + I verify that the sale order is marked as delivered - !python {model: sale.order}: | so = self.browse(cr, uid, ref("sale_order_so7")) diff --git a/addons/sale/test/postpaid_order_policy.yml b/addons/sale/test/postpaid_order_policy.yml index 330c6d17308..a0d5a8e1928 100644 --- a/addons/sale/test/postpaid_order_policy.yml +++ b/addons/sale/test/postpaid_order_policy.yml @@ -45,18 +45,11 @@ if picking_id: pick=self.browse(cr,uid,picking_id[0]) pick.force_assign(cr, uid) - partial_datas = { - 'partner_id':pick.address_id.partner_id.id, - 'address_id': pick.address_id.id, - 'delivery_date' : time.strftime('%Y-%m-%d'), - } - move = pick.move_lines[0] - partial_datas['move%s'%(move.id)]= { - 'product_id': move.product_id.id, - 'product_qty': move.product_qty, - 'product_uom': move.product_uom.id, - } - self.do_partial(cr, uid, [pick.id],partial_datas) + stock_partial_picking = self.pool.get('stock.partial.picking') + partial_id = stock_partial_picking.create(cr, uid, {}, + context={'active_model': 'stock.picking', + 'active_ids': [pick.id]}) + stock_partial_picking.do_partial(cr, uid, [partial_id]) - I verify that picking order is in done state. - @@ -76,7 +69,7 @@ picking_id = self.search(cr, uid, [('origin','=',so.name)]) assert (picking_id),"Delivery order has not been generated" - - I click on the Products Sent button and then on the Validate button + I process the delivery order - !python {model: stock.picking }: | import time @@ -86,20 +79,13 @@ if picking_id: pick=self.browse(cr,uid,picking_id[0]) pick.force_assign(cr, uid) - partial_datas = { - 'partner_id':pick.address_id.partner_id.id, - 'address_id': pick.address_id.id, - 'delivery_date' : time.strftime('%Y-%m-%d'), - } - move = pick.move_lines[0] - partial_datas['move%s'%(move.id)]= { - 'product_id': move.product_id.id, - 'product_qty': move.product_qty, - 'product_uom': move.product_uom.id, - } - self.do_partial(cr, uid, [pick.id],partial_datas) + stock_partial_picking = self.pool.get('stock.partial.picking') + partial_id = stock_partial_picking.create(cr, uid, {}, + context={'active_model': 'stock.picking', + 'active_ids': [pick.id]}) + stock_partial_picking.do_partial(cr, uid, [partial_id]) - - I verify that delivery state is done + I verify that delivery order is marked done - !python {model: stock.picking }: | sale_order_obj = self.pool.get('sale.order') @@ -187,7 +173,7 @@ for pur in pur_ids: wf_service.trg_validate(uid, 'purchase.order',pur,'purchase_approve', cr) - - I verify that a picking related to purchase order has been generated. + I verify that a picking related to purchase order has been generated and I process it - !python {model: sale.order}: | modules = self.pool.get('ir.module.module') @@ -199,31 +185,14 @@ pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)]) po = pur_obj.browse(cr, uid, pur_id)[0] assert(po.picking_ids),"Picking for purchase order has not been generated" + picking, = po.picking_ids + stock_partial_picking = self.pool.get('stock.partial.picking') + partial_id = stock_partial_picking.create(cr, uid, {}, + context={'active_model': 'stock.picking', + 'active_ids': [picking.id]}) + stock_partial_picking.do_partial(cr, uid, [partial_id]) - - Then I click on the "Products Received" button of Incoming Shipments -- - !record {model: stock.partial.picking, id: stock_partial_picking_0}: - date: !eval time.strftime('%Y-%m-%d %H:%M:%S') -- - I click on the "Validate" button -- - !python {model: stock.picking}: | - modules = self.pool.get('ir.module.module') - mod_pur = modules.search(cr, uid, [('name','=','purchase')]) - mod_brw = modules.browse(cr,uid,mod_pur)[0] - if (mod_brw.state == 'installed'): - sale_order_obj = self.pool.get('sale.order') - pur_obj = self.pool.get('purchase.order') - so = sale_order_obj.browse(cr, uid, ref("sale_order_so8")) - pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)]) - po = pur_obj.browse(cr, uid, pur_id)[0] - pick_ser_id = self.search(cr, uid, [('purchase_id', '=', po.id )]) - import netsvc - wf_service = netsvc.LocalService("workflow") - for pick in pick_ser_id: - wf_service.trg_validate(uid, 'stock.picking',pick,'button_done', cr) -- - I verify that picking for purchase order has been done. + I verify that picking for purchase order has been marked done. - !python {model: sale.order}: | from tools.translate import _ @@ -239,7 +208,7 @@ ids = picking_obj.search(cr, uid, [('purchase_id', '=', po.id ),('state', '=', 'done')]) assert ids, _('Picking is not in the done state!') - - I verify that a "Picked" has been set to true + I verify that the sale order is marked as delivered - !python {model: sale.order}: | so = self.browse(cr, uid, ref("sale_order_so8")) diff --git a/addons/sale/test/prepaid_order_policy.yml b/addons/sale/test/prepaid_order_policy.yml index 4bf132e5bee..d6f3da64a2c 100644 --- a/addons/sale/test/prepaid_order_policy.yml +++ b/addons/sale/test/prepaid_order_policy.yml @@ -101,18 +101,11 @@ if picking_id: pick=self.browse(cr,uid,picking_id[0]) pick.force_assign(cr, uid) - partial_datas = { - 'partner_id':pick.address_id.partner_id.id, - 'address_id': pick.address_id.id, - 'delivery_date' : time.strftime('%Y-%m-%d'), - } - move = pick.move_lines[0] - partial_datas['move%s'%(move.id)]= { - 'product_id': move.product_id.id, - 'product_qty': move.product_qty, - 'product_uom': move.product_uom.id, - } - self.do_partial(cr, uid, [pick.id],partial_datas) + stock_partial_picking = self.pool.get('stock.partial.picking') + partial_id = stock_partial_picking.create(cr, uid, {}, + context={'active_model': 'stock.picking', + 'active_ids': [pick.id]}) + stock_partial_picking.do_partial(cr, uid, [partial_id]) - I verify that picking order is in done state. - @@ -201,7 +194,7 @@ for pur in pur_ids: wf_service.trg_validate(uid, 'purchase.order',pur,'purchase_approve', cr) - - I verify that a picking related to purchase order has been generated. + I verify that a picking related to purchase order has been generated and I process it - !python {model: sale.order}: | modules = self.pool.get('ir.module.module') @@ -213,51 +206,21 @@ pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)]) po = pur_obj.browse(cr, uid, pur_id)[0] assert(po.picking_ids),"Picking for purchase order has not been generated" -- - Then I click on the "Products Received" button of Incoming Shipments -- - !record {model: stock.partial.picking, id: stock_partial_picking_0}: - date: !eval time.strftime('%Y-%m-%d %H:%M:%S') -- - I click on the "Validate" button -- - !python {model: stock.picking}: | - modules = self.pool.get('ir.module.module') - sale_order_obj = self.pool.get('sale.order') - pur_obj = self.pool.get('purchase.order') - mod_pur = modules.search(cr, uid, [('name','=','purchase')]) - mod_brw = modules.browse(cr,uid,mod_pur)[0] - if (mod_brw.state == 'installed'): - so = sale_order_obj.browse(cr, uid, ref("sale_order_so1")) - pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)]) - po = pur_obj.browse(cr, uid, pur_id)[0] - pick_ser_id = self.search(cr, uid, [('purchase_id', '=', po.id )]) - import netsvc - wf_service = netsvc.LocalService("workflow") - for pick in pick_ser_id: - wf_service.trg_validate(uid, 'stock.picking',pick,'button_done', cr) -- - I verify that picking for purchase order has been done. -- - !python {model: sale.order}: | - from tools.translate import _ - modules = self.pool.get('ir.module.module') - mod_pur = modules.search(cr, uid, [('name','=','purchase')]) - mod_brw = modules.browse(cr,uid,mod_pur)[0] - if(mod_brw.state == 'installed'): - pur_obj = self.pool.get('purchase.order') - so = self.browse(cr, uid, ref("sale_order_so1")) - pur_id = pur_obj.search(cr, uid, [('origin','=',so.name)]) - po = pur_obj.browse(cr, uid, pur_id)[0] + picking, = po.picking_ids + stock_partial_picking = self.pool.get('stock.partial.picking') + partial_id = stock_partial_picking.create(cr, uid, {}, + context={'active_model': 'stock.picking', + 'active_ids': [picking.id]}) + stock_partial_picking.do_partial(cr, uid, [partial_id]) picking_obj = self.pool.get('stock.picking') - ids = picking_obj.search(cr, uid, [('purchase_id', '=', po.id ),('state', '=', 'done')]) - assert ids, _('Picking is not in the done state!') + ids = picking_obj.search(cr, uid, [('purchase_id', '=', po.id),('state', '=', 'done')]) + assert ids, 'Picking should be marked done!' - - I verify that a "Picked" has been set to true + I verify that the sale order is marked as delivered - !python {model: sale.order}: | so = self.browse(cr, uid, ref("sale_order_so1")) - assert (so.shipped == True), "Picking is not done." + assert (so.shipped == True), "Sale order is not marked as delivered" - I verify that a sale order is in done state - diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 283b9247b63..6d86efa1d22 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -664,8 +664,8 @@ class stock_picking(osv.osv): def action_process(self, cr, uid, ids, context=None): if context is None: context = {} - partial_id = self.pool.get("stock.partial.picking").create( - cr, uid, {}, context=dict(context, active_ids=ids)) + context = dict(context, active_ids=ids, active_model=self._name) + partial_id = self.pool.get("stock.partial.picking").create(cr, uid, {}, context=context) return { 'name':_("Products to Process"), 'view_mode': 'form', @@ -677,7 +677,7 @@ class stock_picking(osv.osv): 'nodestroy': True, 'target': 'new', 'domain': '[]', - 'context': dict(context, active_ids=ids) + 'context': context, } def copy(self, cr, uid, id, default=None, context=None): @@ -1470,6 +1470,8 @@ class stock_move(osv.osv): def action_partial_move(self, cr, uid, ids, context=None): if context is None: context = {} + if context.get('active_model') != self._name: + context.update(active_ids=ids, active_model=self._name) partial_id = self.pool.get("stock.partial.move").create( cr, uid, {}, context=context) return { @@ -2123,14 +2125,9 @@ class stock_move(osv.osv): """ Makes the move done and if all moves are done, it will finish the picking. @return: """ - partial_datas='' picking_ids = [] move_ids = [] - partial_obj=self.pool.get('stock.partial.picking') wf_service = netsvc.LocalService("workflow") - partial_id=partial_obj.search(cr,uid,[]) - if partial_id: - partial_datas = partial_obj.read(cr, uid, partial_id, context=context)[0] if context is None: context = {} @@ -2160,9 +2157,6 @@ class stock_move(osv.osv): self.action_done(cr, uid, [move.move_dest_id.id], context=context) self._create_product_valuation_moves(cr, uid, move, context=context) - prodlot_id = partial_datas and partial_datas.get('move%s_prodlot_id' % (move.id), False) - if prodlot_id: - self.write(cr, uid, [move.id], {'prodlot_id': prodlot_id}, context=context) if move.state not in ('confirmed','done','assigned'): todo.append(move.id) diff --git a/addons/stock/test/stock_test.yml b/addons/stock/test/stock_test.yml index 6a82846492d..66029a62da3 100644 --- a/addons/stock/test/stock_test.yml +++ b/addons/stock/test/stock_test.yml @@ -287,16 +287,9 @@ - !python {model: stock.picking }: | import time - pick=self.browse(cr,uid,ref('stock_picking_0')) - move =pick.move_lines[0] - partial_datas = { - 'partner_id':pick.address_id.partner_id.id, - 'address_id': pick.address_id.id, - 'delivery_date' : time.strftime('%Y-%m-%d') - } - partial_datas['move%s'%(move.id)]= { - 'product_id': move.product_id, - 'product_qty': move.product_qty, - 'product_uom': move.product_uom.id, - } - self.do_partial(cr, uid, [ref('stock_picking_0')],partial_datas) + pick = self.browse(cr,uid,ref('stock_picking_0')) + stock_partial_picking = self.pool.get('stock.partial.picking') + partial_id = stock_partial_picking.create(cr, uid, {}, + context={'active_model': 'stock.picking', + 'active_ids': [pick.id]}) + stock_partial_picking.do_partial(cr, uid, [partial_id]) diff --git a/addons/stock/wizard/stock_partial_move.py b/addons/stock/wizard/stock_partial_move.py index 0f7200309f6..ec348656ce0 100644 --- a/addons/stock/wizard/stock_partial_move.py +++ b/addons/stock/wizard/stock_partial_move.py @@ -2,7 +2,7 @@ ############################################################################## # # OpenERP, Open Source Management Solution -# Copyright (C) 2004-2010 Tiny SPRL (). +# Copyright (C) 2004-TODAY OpenERP 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,204 +20,65 @@ ############################################################################## from osv import fields, osv -from tools.translate import _ +from tools.misc import DEFAULT_SERVER_DATETIME_FORMAT import time -import decimal_precision as dp +class stock_partial_move_line(osv.osv_memory): + _inherit = "stock.partial.picking.line" + _name = "stock.partial.move.line" + _columns = { + 'wizard_id' : fields.many2one('stock.partial.move', string="Wizard", ondelete='CASCADE'), + } -class stock_partial_move_memory_out(osv.osv_memory): - _inherit = "stock.picking.memory.out" - _name = "stock.move.memory.out" - _columns = { - 'wizard_id' : fields.many2one('stock.partial.move', string="Wizard"), - } - -class stock_partial_move_memory_in(osv.osv_memory): - _inherit = "stock.picking.memory.in" - _name = "stock.move.memory.in" - _columns = { - 'wizard_id' : fields.many2one('stock.partial.move', string="Wizard"), - } - class stock_partial_move(osv.osv_memory): _name = "stock.partial.move" - _description = "Partial Move" + _inherit = 'stock.partial.picking' + _description = "Partial Move Processing Wizard" _columns = { 'date': fields.datetime('Date', required=True), - 'type': fields.char("Type", size=3), - 'product_moves_out' : fields.one2many('stock.move.memory.out', 'wizard_id', 'Moves'), - 'product_moves_in' : fields.one2many('stock.move.memory.in', 'wizard_id', 'Moves'), - } - - - def __is_in(self,cr, uid, move_ids): - """ - @return: True if one of the moves has as picking type 'in' - """ - if not move_ids: - return False - - move_obj = self.pool.get('stock.move') - move_ids = move_obj.search(cr, uid, [('id','in',move_ids)]) - - for move in move_obj.browse(cr, uid, move_ids): - if move.picking_id.type == 'in' and move.product_id.cost_method == 'average': - return True - return False - - def __get_picking_type(self, cr, uid, move_ids): - if self.__is_in(cr, uid, move_ids): - return "product_moves_in" - else: - return "product_moves_out" - - def view_init(self, cr, uid, fields_list, context=None): - res = super(stock_partial_move, self).view_init(cr, uid, fields_list, context=context) - move_obj = self.pool.get('stock.move') - - if context is None: - context = {} - for move in move_obj.browse(cr, uid, context.get('active_ids', []), context=context): - if move.state in ('done', 'cancel'): - raise osv.except_osv(_('Invalid action !'), _('Cannot deliver products which are already delivered !')) - - return res - - - def __create_partial_move_memory(self, move): - move_memory = { - 'product_id' : move.product_id.id, - 'quantity' : move.product_qty, - 'product_uom' : move.product_uom.id, - 'prodlot_id' : move.prodlot_id.id, - 'move_id' : move.id, - } - - if move.picking_id.type == 'in': - move_memory.update({ - 'cost' : move.product_id.standard_price, - 'currency' : move.product_id.company_id and move.product_id.company_id.currency_id and move.product_id.company_id.currency_id.id or False, - }) - return move_memory + 'move_ids' : fields.one2many('stock.partial.move.line', 'wizard_id', 'Moves'), - def __get_active_stock_moves(self, cr, uid, context=None): - move_obj = self.pool.get('stock.move') - if context is None: - context = {} - - res = [] - for move in move_obj.browse(cr, uid, context.get('active_ids', []), context=context): - if move.state in ('done', 'cancel'): - continue - res.append(self.__create_partial_move_memory(move)) - + # picking_id is not used for move processing, so we remove the required attribute + # from the inherited column, and ignore it + 'picking_id': fields.many2one('stock.picking', 'Picking'), + } + + def default_get(self, cr, uid, fields, context=None): + if context is None: context = {} + # no call to super! + res = {} + move_ids = context.get('active_ids', []) + if not move_ids or not context.get('active_model') == 'stock.move': + return res + if 'move_ids' in fields: + move_ids = self.pool.get('stock.move').browse(cr, uid, move_ids, context=context) + moves = [self._partial_move_for(cr, uid, m) for m in move_ids if m.state not in ('done','cancel')] + res.update(move_ids=moves) + if 'date' in fields: + res.update(date=time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)) return res - - _defaults = { - 'product_moves_in' : __get_active_stock_moves, - 'product_moves_out' : __get_active_stock_moves, - 'date' : lambda *a : time.strftime('%Y-%m-%d %H:%M:%S'), - } - - - def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False): - if not context: - context = {} - - message = { - 'title' : _('Deliver Products'), - 'info' : _('Delivery Information'), - 'button' : _('Deliver'), - } - if context: - if context.get('product_receive', False): - message = { - 'title' : _('Receive Products'), - 'info' : _('Receive Information'), - 'button' : _('Receive'), - } - - move_ids = context.get('active_ids', False) - message['picking_type'] = self.__get_picking_type(cr, uid, move_ids) - result = super(stock_partial_move, self).fields_view_get(cr, uid, view_id, view_type, context, toolbar, submenu) - _moves_fields = result['fields'] - _moves_fields.update({ - 'product_moves_in' : {'relation': 'stock.move.memory.in', 'type' : 'one2many', 'string' : 'Product Moves'}, - 'product_moves_out' : {'relation': 'stock.move.memory.out', 'type' : 'one2many', 'string' : 'Product Moves'} - }) - - _moves_arch_lst = """ -
- - - - - -