Merge lp:~openerp-dev/openobject-addons/trunk-workflow-context-odo into lp:openobject-addons

Proposed by Olivier Dony (Odoo)
Status: Work in progress
Proposed branch: lp:~openerp-dev/openobject-addons/trunk-workflow-context-odo
Merge into: lp:openobject-addons
Diff against target: 1045 lines (+147/-143) (has conflicts)
11 files modified
account/account_invoice.py (+18/-19)
hr_expense/hr_expense.py (+5/-5)
hr_payroll/hr_payroll.py (+2/-2)
mrp/mrp.py (+18/-18)
mrp/procurement.py (+2/-2)
mrp_operations/mrp_operations.py (+17/-17)
procurement/procurement.py (+10/-10)
purchase/purchase.py (+21/-20)
sale/sale.py (+29/-25)
stock/stock.py (+21/-21)
stock_location/procurement_pull.py (+4/-4)
Text conflict in sale/sale.py
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/trunk-workflow-context-odo
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+85530@code.launchpad.net

Description of the change

Work in progress for passing context in business methods who are calling workflows directly or being called by workflows, and as much as possible, downstream.
Basically this boils downs to adding and passing context for all methods on workflow-enabled models, which is a lot of work and dangerous enough... Perhaps a first step instead would be to only care about supporting a context parameter in methods that are directly called by workflows. These are easy to identify, and there is a lot less work to do, _but_ the result will be quite disappointing, as anything beyond the first stack frame downstream of the workflow will likely never see the context anyway.

This branch is not complete yet, and this work is probably too sensitive at this point of releasing 6.1.
See also the prerequisite server branch lp:~openerp-dev/openobject-server/trunk-workflow-context-odo

To post a comment you must log in.

Unmerged revisions

5838. By Olivier Dony (Odoo)

[IMP] workflows: accept and propagate context during workflow execution (wip)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account/account_invoice.py'
--- account/account_invoice.py 2011-12-06 10:13:54 +0000
+++ account/account_invoice.py 2011-12-13 18:03:48 +0000
@@ -466,7 +466,7 @@
466 }466 }
467 return result467 return result
468468
469 def onchange_payment_term_date_invoice(self, cr, uid, ids, payment_term_id, date_invoice):469 def onchange_payment_term_date_invoice(self, cr, uid, ids, payment_term_id, date_invoice, context=None):
470 if not payment_term_id:470 if not payment_term_id:
471 return {}471 return {}
472 res = {}472 res = {}
@@ -578,12 +578,12 @@
578 return {'value': val, 'domain': dom}578 return {'value': val, 'domain': dom}
579579
580 # go from canceled state to draft state580 # go from canceled state to draft state
581 def action_cancel_draft(self, cr, uid, ids, *args):581 def action_cancel_draft(self, cr, uid, ids, context=None):
582 self.write(cr, uid, ids, {'state':'draft'})582 self.write(cr, uid, ids, {'state':'draft'})
583 wf_service = netsvc.LocalService("workflow")583 wf_service = netsvc.LocalService("workflow")
584 for inv_id in ids:584 for inv_id in ids:
585 wf_service.trg_delete(uid, 'account.invoice', inv_id, cr)585 wf_service.trg_delete(uid, 'account.invoice', inv_id, cr, context=context)
586 wf_service.trg_create(uid, 'account.invoice', inv_id, cr)586 wf_service.trg_create(uid, 'account.invoice', inv_id, cr, context=context)
587 return True587 return True
588588
589 # Workflow stuff589 # Workflow stuff
@@ -591,12 +591,12 @@
591591
592 # return the ids of the move lines which has the same account than the invoice592 # return the ids of the move lines which has the same account than the invoice
593 # whose id is in ids593 # whose id is in ids
594 def move_line_id_payment_get(self, cr, uid, ids, *args):594 def move_line_id_payment_get(self, cr, uid, ids, context=None):
595 if not ids: return []595 if not ids: return []
596 result = self.move_line_id_payment_gets(cr, uid, ids, *args)596 result = self.move_line_id_payment_gets(cr, uid, ids, context=context)
597 return result.get(ids[0], [])597 return result.get(ids[0], [])
598598
599 def move_line_id_payment_gets(self, cr, uid, ids, *args):599 def move_line_id_payment_gets(self, cr, uid, ids, context=None):
600 res = {}600 res = {}
601 if not ids: return res601 if not ids: return res
602 cr.execute('SELECT i.id, l.id '\602 cr.execute('SELECT i.id, l.id '\
@@ -630,8 +630,8 @@
630 })630 })
631 return super(account_invoice, self).copy(cr, uid, id, default, context)631 return super(account_invoice, self).copy(cr, uid, id, default, context)
632632
633 def test_paid(self, cr, uid, ids, *args):633 def test_paid(self, cr, uid, ids, context=None):
634 res = self.move_line_id_payment_get(cr, uid, ids)634 res = self.move_line_id_payment_get(cr, uid, ids, context=context)
635 if not res:635 if not res:
636 return False636 return False
637 ok = True637 ok = True
@@ -701,14 +701,14 @@
701 })]701 })]
702 return iml702 return iml
703703
704 def action_date_assign(self, cr, uid, ids, *args):704 def action_date_assign(self, cr, uid, ids, context=None):
705 for inv in self.browse(cr, uid, ids):705 for inv in self.browse(cr, uid, ids):
706 res = self.onchange_payment_term_date_invoice(cr, uid, inv.id, inv.payment_term.id, inv.date_invoice)706 res = self.onchange_payment_term_date_invoice(cr, uid, inv.id, inv.payment_term.id, inv.date_invoice, context=context)
707 if res and res['value']:707 if res and res['value']:
708 self.write(cr, uid, [inv.id], res['value'])708 self.write(cr, uid, [inv.id], res['value'])
709 return True709 return True
710710
711 def finalize_invoice_move_lines(self, cr, uid, invoice_browse, move_lines):711 def finalize_invoice_move_lines(self, cr, uid, invoice_browse, move_lines, context=None):
712 """finalize_invoice_move_lines(cr, uid, invoice, move_lines) -> move_lines712 """finalize_invoice_move_lines(cr, uid, invoice, move_lines) -> move_lines
713 Hook method to be overridden in additional modules to verify and possibly alter the713 Hook method to be overridden in additional modules to verify and possibly alter the
714 move lines to be created by an invoice, for special cases.714 move lines to be created by an invoice, for special cases.
@@ -794,12 +794,13 @@
794 line.append((0,0,val))794 line.append((0,0,val))
795 return line795 return line
796796
797 def action_move_create(self, cr, uid, ids, *args):797 def action_move_create(self, cr, uid, ids, context=None):
798 """Creates invoice related analytics and financial move lines"""798 """Creates invoice related analytics and financial move lines"""
799 ait_obj = self.pool.get('account.invoice.tax')799 ait_obj = self.pool.get('account.invoice.tax')
800 cur_obj = self.pool.get('res.currency')800 cur_obj = self.pool.get('res.currency')
801 period_obj = self.pool.get('account.period')801 period_obj = self.pool.get('account.period')
802 context = {}802 if context is None:
803 context = {}
803 for inv in self.browse(cr, uid, ids):804 for inv in self.browse(cr, uid, ids):
804 if not inv.journal_id.sequence_id:805 if not inv.journal_id.sequence_id:
805 raise osv.except_osv(_('Error !'), _('Please define sequence on invoice journal'))806 raise osv.except_osv(_('Error !'), _('Please define sequence on invoice journal'))
@@ -815,8 +816,7 @@
815 # one move line per invoice line816 # one move line per invoice line
816 iml = self._get_analytic_lines(cr, uid, inv.id)817 iml = self._get_analytic_lines(cr, uid, inv.id)
817 # check if taxes are all computed818 # check if taxes are all computed
818 ctx = context.copy()819 ctx = dict(context, lang=inv.partner_id.lang)
819 ctx.update({'lang': inv.partner_id.lang})
820 compute_taxes = ait_obj.compute(cr, uid, inv.id, context=ctx)820 compute_taxes = ait_obj.compute(cr, uid, inv.id, context=ctx)
821 self.check_tax_lines(cr, uid, inv, compute_taxes, ait_obj)821 self.check_tax_lines(cr, uid, inv, compute_taxes, ait_obj)
822822
@@ -916,7 +916,7 @@
916 raise osv.except_osv(_('UserError'),916 raise osv.except_osv(_('UserError'),
917 _('You cannot create an invoice on a centralised journal. Uncheck the centralised counterpart box in the related journal from the configuration menu.'))917 _('You cannot create an invoice on a centralised journal. Uncheck the centralised counterpart box in the related journal from the configuration menu.'))
918918
919 line = self.finalize_invoice_move_lines(cr, uid, inv, line)919 line = self.finalize_invoice_move_lines(cr, uid, inv, line, context=context)
920920
921 move = {921 move = {
922 'ref': inv.reference and inv.reference or inv.name,922 'ref': inv.reference and inv.reference or inv.name,
@@ -1009,8 +1009,7 @@
1009 self.log(cr, uid, inv_id, message, context=ctx)1009 self.log(cr, uid, inv_id, message, context=ctx)
1010 return True1010 return True
10111011
1012 def action_cancel(self, cr, uid, ids, *args):1012 def action_cancel(self, cr, uid, ids, context=None):
1013 context = {} # TODO: Use context from arguments
1014 account_move_obj = self.pool.get('account.move')1013 account_move_obj = self.pool.get('account.move')
1015 invoices = self.read(cr, uid, ids, ['move_id', 'payment_ids'])1014 invoices = self.read(cr, uid, ids, ['move_id', 'payment_ids'])
1016 move_ids = [] # ones that we will need to remove1015 move_ids = [] # ones that we will need to remove
10171016
=== modified file 'hr_expense/hr_expense.py'
--- hr_expense/hr_expense.py 2011-11-28 08:06:57 +0000
+++ hr_expense/hr_expense.py 2011-12-13 18:03:48 +0000
@@ -105,14 +105,14 @@
105 company_id = employee.company_id.id105 company_id = employee.company_id.id
106 return {'value': {'department_id': department_id, 'company_id': company_id}}106 return {'value': {'department_id': department_id, 'company_id': company_id}}
107107
108 def expense_confirm(self, cr, uid, ids, *args):108 def expense_confirm(self, cr, uid, ids, context=None):
109 self.write(cr, uid, ids, {109 self.write(cr, uid, ids, {
110 'state':'confirm',110 'state':'confirm',
111 'date_confirm': time.strftime('%Y-%m-%d')111 'date_confirm': time.strftime('%Y-%m-%d')
112 })112 })
113 return True113 return True
114114
115 def expense_accept(self, cr, uid, ids, *args):115 def expense_accept(self, cr, uid, ids, context=None):
116 self.write(cr, uid, ids, {116 self.write(cr, uid, ids, {
117 'state':'accepted',117 'state':'accepted',
118 'date_valid':time.strftime('%Y-%m-%d'),118 'date_valid':time.strftime('%Y-%m-%d'),
@@ -120,11 +120,11 @@
120 })120 })
121 return True121 return True
122122
123 def expense_canceled(self, cr, uid, ids, *args):123 def expense_canceled(self, cr, uid, ids, context=None):
124 self.write(cr, uid, ids, {'state':'cancelled'})124 self.write(cr, uid, ids, {'state':'cancelled'})
125 return True125 return True
126126
127 def expense_paid(self, cr, uid, ids, *args):127 def expense_paid(self, cr, uid, ids, context=None):
128 self.write(cr, uid, ids, {'state':'paid'})128 self.write(cr, uid, ids, {'state':'paid'})
129 return True129 return True
130130
@@ -149,7 +149,7 @@
149 'res_id': inv_ids and inv_ids[0] or False,149 'res_id': inv_ids and inv_ids[0] or False,
150 }150 }
151151
152 def action_invoice_create(self, cr, uid, ids):152 def action_invoice_create(self, cr, uid, ids, context=None):
153 res = False153 res = False
154 invoice_obj = self.pool.get('account.invoice')154 invoice_obj = self.pool.get('account.invoice')
155 property_obj = self.pool.get('ir.property')155 property_obj = self.pool.get('ir.property')
156156
=== modified file 'hr_payroll/hr_payroll.py'
--- hr_payroll/hr_payroll.py 2011-11-30 14:01:07 +0000
+++ hr_payroll/hr_payroll.py 2011-12-13 18:03:48 +0000
@@ -336,8 +336,8 @@
336 for payslip in self.browse(cr, uid, ids, context=context):336 for payslip in self.browse(cr, uid, ids, context=context):
337 id_copy = self.copy(cr, uid, payslip.id, {'credit_note': True, 'name': _('Refund: ')+payslip.name}, context=context)337 id_copy = self.copy(cr, uid, payslip.id, {'credit_note': True, 'name': _('Refund: ')+payslip.name}, context=context)
338 self.compute_sheet(cr, uid, [id_copy], context=context)338 self.compute_sheet(cr, uid, [id_copy], context=context)
339 wf_service.trg_validate(uid, 'hr.payslip', id_copy, 'hr_verify_sheet', cr)339 wf_service.trg_validate(uid, 'hr.payslip', id_copy, 'hr_verify_sheet', cr, context=context)
340 wf_service.trg_validate(uid, 'hr.payslip', id_copy, 'process_sheet', cr)340 wf_service.trg_validate(uid, 'hr.payslip', id_copy, 'process_sheet', cr, context=context)
341341
342 form_id = mod_obj.get_object_reference(cr, uid, 'hr_payroll', 'view_hr_payslip_form')342 form_id = mod_obj.get_object_reference(cr, uid, 'hr_payroll', 'view_hr_payslip_form')
343 form_res = form_id and form_id[1] or False343 form_res = form_id and form_id[1] or False
344344
=== modified file 'mrp/mrp.py'
--- mrp/mrp.py 2011-12-06 08:12:49 +0000
+++ mrp/mrp.py 2011-12-13 18:03:48 +0000
@@ -585,14 +585,14 @@
585 }585 }
586 return {'value': result}586 return {'value': result}
587587
588 def action_picking_except(self, cr, uid, ids):588 def action_picking_except(self, cr, uid, ids, context=None):
589 """ Changes the state to Exception.589 """ Changes the state to Exception.
590 @return: True590 @return: True
591 """591 """
592 self.write(cr, uid, ids, {'state': 'picking_except'})592 self.write(cr, uid, ids, {'state': 'picking_except'})
593 return True593 return True
594594
595 def action_compute(self, cr, uid, ids, properties=[]):595 def action_compute(self, cr, uid, ids, properties=[], context=None):
596 """ Computes bills of material of a product.596 """ Computes bills of material of a product.
597 @param properties: List containing dictionaries of properties.597 @param properties: List containing dictionaries of properties.
598 @return: No. of products.598 @return: No. of products.
@@ -663,15 +663,15 @@
663 self.log(cr, uid, production_id, message)663 self.log(cr, uid, production_id, message)
664 return True664 return True
665665
666 def action_production_end(self, cr, uid, ids):666 def action_production_end(self, cr, uid, ids, context=None):
667 """ Changes production state to Finish and writes finished date.667 """ Changes production state to Finish and writes finished date.
668 @return: True668 @return: True
669 """669 """
670 for production in self.browse(cr, uid, ids):670 for production in self.browse(cr, uid, ids, context=context):
671 self._costs_generate(cr, uid, production)671 self._costs_generate(cr, uid, production, context=context)
672 return self.write(cr, uid, ids, {'state': 'done', 'date_finished': time.strftime('%Y-%m-%d %H:%M:%S')})672 return self.write(cr, uid, ids, {'state': 'done', 'date_finished': time.strftime('%Y-%m-%d %H:%M:%S')})
673673
674 def test_production_done(self, cr, uid, ids):674 def test_production_done(self, cr, uid, ids, context=None):
675 """ Tests whether production is done or not.675 """ Tests whether production is done or not.
676 @return: True or False676 @return: True or False
677 """677 """
@@ -791,7 +791,7 @@
791 wf_service.trg_validate(uid, 'mrp.production', production_id, 'button_produce_done', cr)791 wf_service.trg_validate(uid, 'mrp.production', production_id, 'button_produce_done', cr)
792 return True792 return True
793793
794 def _costs_generate(self, cr, uid, production):794 def _costs_generate(self, cr, uid, production, context=None):
795 """ Calculates total costs at the end of the production.795 """ Calculates total costs at the end of the production.
796 @param production: Id of production order.796 @param production: Id of production order.
797 @return: Calculated amount.797 @return: Calculated amount.
@@ -834,14 +834,14 @@
834 } )834 } )
835 return amount835 return amount
836836
837 def action_in_production(self, cr, uid, ids):837 def action_in_production(self, cr, uid, ids, context=None):
838 """ Changes state to In Production and writes starting date.838 """ Changes state to In Production and writes starting date.
839 @return: True839 @return: True
840 """840 """
841 self.write(cr, uid, ids, {'state': 'in_production', 'date_start': time.strftime('%Y-%m-%d %H:%M:%S')})841 self.write(cr, uid, ids, {'state': 'in_production', 'date_start': time.strftime('%Y-%m-%d %H:%M:%S')})
842 return True842 return True
843843
844 def test_if_product(self, cr, uid, ids):844 def test_if_product(self, cr, uid, ids, context=None):
845 """845 """
846 @return: True or False846 @return: True or False
847 """847 """
@@ -852,10 +852,10 @@
852 res = False852 res = False
853 return res853 return res
854854
855 def _get_auto_picking(self, cr, uid, production):855 def _get_auto_picking(self, cr, uid, production, context=None):
856 return True856 return True
857857
858 def action_confirm(self, cr, uid, ids):858 def action_confirm(self, cr, uid, ids, context=None):
859 """ Confirms production order.859 """ Confirms production order.
860 @return: Newly generated picking Id.860 @return: Newly generated picking Id.
861 """861 """
@@ -866,10 +866,10 @@
866 move_obj = self.pool.get('stock.move')866 move_obj = self.pool.get('stock.move')
867 proc_obj = self.pool.get('procurement.order')867 proc_obj = self.pool.get('procurement.order')
868 wf_service = netsvc.LocalService("workflow")868 wf_service = netsvc.LocalService("workflow")
869 for production in self.browse(cr, uid, ids):869 for production in self.browse(cr, uid, ids, context=context):
870 if not production.product_lines:870 if not production.product_lines:
871 self.action_compute(cr, uid, [production.id])871 self.action_compute(cr, uid, [production.id], context=context)
872 production = self.browse(cr, uid, [production.id])[0]872 production = self.browse(cr, uid, [production.id], context=context)[0]
873 routing_loc = None873 routing_loc = None
874 pick_type = 'internal'874 pick_type = 'internal'
875 address_id = False875 address_id = False
@@ -958,9 +958,9 @@
958 'move_id': move_id,958 'move_id': move_id,
959 'company_id': production.company_id.id,959 'company_id': production.company_id.id,
960 })960 })
961 wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr)961 wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr, context=context)
962 proc_ids.append(proc_id)962 proc_ids.append(proc_id)
963 wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)963 wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr, context=context)
964 self.write(cr, uid, [production.id], {'picking_id': picking_id, 'move_lines': [(6,0,moves)], 'state':'confirmed'})964 self.write(cr, uid, [production.id], {'picking_id': picking_id, 'move_lines': [(6,0,moves)], 'state':'confirmed'})
965 message = _("Manufacturing order '%s' is scheduled for the %s.") % (965 message = _("Manufacturing order '%s' is scheduled for the %s.") % (
966 production.name,966 production.name,
@@ -969,13 +969,13 @@
969 self.log(cr, uid, production.id, message)969 self.log(cr, uid, production.id, message)
970 return picking_id970 return picking_id
971971
972 def force_production(self, cr, uid, ids, *args):972 def force_production(self, cr, uid, ids, context=None):
973 """ Assigns products.973 """ Assigns products.
974 @param *args: Arguments974 @param *args: Arguments
975 @return: True975 @return: True
976 """976 """
977 pick_obj = self.pool.get('stock.picking')977 pick_obj = self.pool.get('stock.picking')
978 pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)])978 pick_obj.force_assign(cr, uid, [prod.picking_id.id for prod in self.browse(cr, uid, ids)], context=context)
979 return True979 return True
980980
981mrp_production()981mrp_production()
982982
=== modified file 'mrp/procurement.py'
--- mrp/procurement.py 2011-09-17 16:41:25 +0000
+++ mrp/procurement.py 2011-12-13 18:03:48 +0000
@@ -33,7 +33,7 @@
33 'property_ids': fields.many2many('mrp.property', 'procurement_property_rel', 'procurement_id','property_id', 'Properties'),33 'property_ids': fields.many2many('mrp.property', 'procurement_property_rel', 'procurement_id','property_id', 'Properties'),
34 }34 }
35 35
36 def check_produce_product(self, cr, uid, procurement, context=[]):36 def check_produce_product(self, cr, uid, procurement, context=None):
37 """ Finds the bill of material for the product from procurement order.37 """ Finds the bill of material for the product from procurement order.
38 @return: True or False38 @return: True or False
39 """39 """
@@ -99,7 +99,7 @@
99 self.write(cr, uid, [procurement.id], {'state': 'running'})99 self.write(cr, uid, [procurement.id], {'state': 'running'})
100 bom_result = production_obj.action_compute(cr, uid,100 bom_result = production_obj.action_compute(cr, uid,
101 [produce_id], properties=[x.id for x in procurement.property_ids])101 [produce_id], properties=[x.id for x in procurement.property_ids])
102 wf_service.trg_validate(uid, 'mrp.production', produce_id, 'button_confirm', cr)102 wf_service.trg_validate(uid, 'mrp.production', produce_id, 'button_confirm', cr, context=context)
103 if res_id:103 if res_id:
104 move_obj.write(cr, uid, [res_id],104 move_obj.write(cr, uid, [res_id],
105 {'location_id': procurement.location_id.id})105 {'location_id': procurement.location_id.id})
106106
=== modified file 'mrp_operations/mrp_operations.py'
--- mrp_operations/mrp_operations.py 2011-12-08 09:49:28 +0000
+++ mrp_operations/mrp_operations.py 2011-12-13 18:03:48 +0000
@@ -156,14 +156,14 @@
156 prod_obj.write(cr, uid, [prod.production_id.id], {'date_start':dstart}, context=context, mini=False)156 prod_obj.write(cr, uid, [prod.production_id.id], {'date_start':dstart}, context=context, mini=False)
157 return result157 return result
158158
159 def action_draft(self, cr, uid, ids):159 def action_draft(self, cr, uid, ids, context=None):
160 """ Sets state to draft.160 """ Sets state to draft.
161 @return: True161 @return: True
162 """162 """
163 self.write(cr, uid, ids, {'state':'draft'})163 self.write(cr, uid, ids, {'state':'draft'})
164 return True164 return True
165165
166 def action_start_working(self, cr, uid, ids):166 def action_start_working(self, cr, uid, ids, context=None):
167 """ Sets state to start working and writes starting date.167 """ Sets state to start working and writes starting date.
168 @return: True168 @return: True
169 """169 """
@@ -171,7 +171,7 @@
171 self.write(cr, uid, ids, {'state':'startworking', 'date_start': time.strftime('%Y-%m-%d %H:%M:%S')})171 self.write(cr, uid, ids, {'state':'startworking', 'date_start': time.strftime('%Y-%m-%d %H:%M:%S')})
172 return True172 return True
173173
174 def action_done(self, cr, uid, ids):174 def action_done(self, cr, uid, ids, context=None):
175 """ Sets state to done, writes finish date and calculates delay.175 """ Sets state to done, writes finish date and calculates delay.
176 @return: True176 @return: True
177 """177 """
@@ -188,21 +188,21 @@
188 self.modify_production_order_state(cr,uid,ids,'done')188 self.modify_production_order_state(cr,uid,ids,'done')
189 return True189 return True
190190
191 def action_cancel(self, cr, uid, ids):191 def action_cancel(self, cr, uid, ids, context=None):
192 """ Sets state to cancel.192 """ Sets state to cancel.
193 @return: True193 @return: True
194 """194 """
195 self.write(cr, uid, ids, {'state':'cancel'})195 self.write(cr, uid, ids, {'state':'cancel'})
196 return True196 return True
197197
198 def action_pause(self, cr, uid, ids):198 def action_pause(self, cr, uid, ids, context=None):
199 """ Sets state to pause.199 """ Sets state to pause.
200 @return: True200 @return: True
201 """201 """
202 self.write(cr, uid, ids, {'state':'pause'})202 self.write(cr, uid, ids, {'state':'pause'})
203 return True203 return True
204204
205 def action_resume(self, cr, uid, ids):205 def action_resume(self, cr, uid, ids, context=None):
206 """ Sets state to startworking.206 """ Sets state to startworking.
207 @return: True207 @return: True
208 """208 """
@@ -228,7 +228,7 @@
228 result[prod.id] = max(line.date_planned_end, result[prod.id])228 result[prod.id] = max(line.date_planned_end, result[prod.id])
229 return result229 return result
230230
231 def action_production_end(self, cr, uid, ids):231 def action_production_end(self, cr, uid, ids, context=None):
232 """ Finishes work order if production order is done.232 """ Finishes work order if production order is done.
233 @return: Super method233 @return: Super method
234 """234 """
@@ -236,11 +236,11 @@
236 wf_service = netsvc.LocalService("workflow")236 wf_service = netsvc.LocalService("workflow")
237 for workcenter_line in obj.workcenter_lines:237 for workcenter_line in obj.workcenter_lines:
238 if workcenter_line.state == 'draft':238 if workcenter_line.state == 'draft':
239 wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_start_working', cr)239 wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_start_working', cr, context=context)
240 wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_done', cr)240 wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_done', cr, context=context)
241 return super(mrp_production,self).action_production_end(cr, uid, ids)241 return super(mrp_production,self).action_production_end(cr, uid, ids, context=context)
242242
243 def action_in_production(self, cr, uid, ids):243 def action_in_production(self, cr, uid, ids, context=None):
244 """ Changes state to In Production and writes starting date.244 """ Changes state to In Production and writes starting date.
245 @return: True245 @return: True
246 """246 """
@@ -249,8 +249,8 @@
249 wf_service = netsvc.LocalService("workflow")249 wf_service = netsvc.LocalService("workflow")
250 for prod in self.browse(cr, uid, ids):250 for prod in self.browse(cr, uid, ids):
251 if prod.workcenter_lines:251 if prod.workcenter_lines:
252 wf_service.trg_validate(uid, 'mrp.production.workcenter.line', prod.workcenter_lines[0].id, 'button_start_working', cr)252 wf_service.trg_validate(uid, 'mrp.production.workcenter.line', prod.workcenter_lines[0].id, 'button_start_working', cr, context=context)
253 return super(mrp_production,self).action_in_production(cr, uid, ids)253 return super(mrp_production,self).action_in_production(cr, uid, ids, context=context)
254 254
255 def action_cancel(self, cr, uid, ids, context=None):255 def action_cancel(self, cr, uid, ids, context=None):
256 """ Cancels work order if production order is canceled.256 """ Cancels work order if production order is canceled.
@@ -259,7 +259,7 @@
259 obj = self.browse(cr, uid, ids,context=context)[0]259 obj = self.browse(cr, uid, ids,context=context)[0]
260 wf_service = netsvc.LocalService("workflow")260 wf_service = netsvc.LocalService("workflow")
261 for workcenter_line in obj.workcenter_lines:261 for workcenter_line in obj.workcenter_lines:
262 wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_cancel', cr)262 wf_service.trg_validate(uid, 'mrp.production.workcenter.line', workcenter_line.id, 'button_cancel', cr, context=context)
263 return super(mrp_production,self).action_cancel(cr,uid,ids,context=context)263 return super(mrp_production,self).action_cancel(cr,uid,ids,context=context)
264264
265 def _compute_planned_workcenter(self, cr, uid, ids, context=None, mini=False):265 def _compute_planned_workcenter(self, cr, uid, ids, context=None, mini=False):
@@ -371,13 +371,13 @@
371 pass371 pass
372 return result372 return result
373373
374 def action_compute(self, cr, uid, ids, properties=[]):374 def action_compute(self, cr, uid, ids, properties=[], context=None):
375 """ Computes bills of material of a product and planned date of work order.375 """ Computes bills of material of a product and planned date of work order.
376 @param properties: List containing dictionaries of properties.376 @param properties: List containing dictionaries of properties.
377 @return: No. of products.377 @return: No. of products.
378 """378 """
379 result = super(mrp_production, self).action_compute(cr, uid, ids, properties=properties)379 result = super(mrp_production, self).action_compute(cr, uid, ids, properties=properties, context=context)
380 self._compute_planned_workcenter(cr, uid, ids, context={})380 self._compute_planned_workcenter(cr, uid, ids, context=context)
381 return result381 return result
382382
383mrp_production()383mrp_production()
384384
=== modified file 'procurement/procurement.py'
--- procurement/procurement.py 2011-12-07 14:58:54 +0000
+++ procurement/procurement.py 2011-12-13 18:03:48 +0000
@@ -410,7 +410,7 @@
410 """410 """
411 return 0411 return 0
412412
413 def action_cancel(self, cr, uid, ids):413 def action_cancel(self, cr, uid, ids, context=None):
414 """ Cancels procurement and writes move state to Assigned.414 """ Cancels procurement and writes move state to Assigned.
415 @return: True415 @return: True
416 """416 """
@@ -431,13 +431,13 @@
431 self.write(cr, uid, ids, {'state': 'cancel'})431 self.write(cr, uid, ids, {'state': 'cancel'})
432 wf_service = netsvc.LocalService("workflow")432 wf_service = netsvc.LocalService("workflow")
433 for id in ids:433 for id in ids:
434 wf_service.trg_trigger(uid, 'procurement.order', id, cr)434 wf_service.trg_trigger(uid, 'procurement.order', id, cr, context=context)
435 return True435 return True
436436
437 def action_check_finished(self, cr, uid, ids):437 def action_check_finished(self, cr, uid, ids, context=None):
438 return self.check_move_done(cr, uid, ids)438 return self.check_move_done(cr, uid, ids)
439439
440 def action_check(self, cr, uid, ids):440 def action_check(self, cr, uid, ids, context=None):
441 """ Checks procurement move state whether assigned or done.441 """ Checks procurement move state whether assigned or done.
442 @return: True442 @return: True
443 """443 """
@@ -448,14 +448,14 @@
448 ok = True448 ok = True
449 return ok449 return ok
450450
451 def action_ready(self, cr, uid, ids):451 def action_ready(self, cr, uid, ids, context=None):
452 """ Changes procurement state to Ready.452 """ Changes procurement state to Ready.
453 @return: True453 @return: True
454 """454 """
455 res = self.write(cr, uid, ids, {'state': 'ready'})455 res = self.write(cr, uid, ids, {'state': 'ready'})
456 return res456 return res
457457
458 def action_done(self, cr, uid, ids):458 def action_done(self, cr, uid, ids, context=None):
459 """ Changes procurement state to Done and writes Closed date.459 """ Changes procurement state to Done and writes Closed date.
460 @return: True460 @return: True
461 """461 """
@@ -463,11 +463,11 @@
463 for procurement in self.browse(cr, uid, ids):463 for procurement in self.browse(cr, uid, ids):
464 if procurement.move_id:464 if procurement.move_id:
465 if procurement.close_move and (procurement.move_id.state <> 'done'):465 if procurement.close_move and (procurement.move_id.state <> 'done'):
466 move_obj.action_done(cr, uid, [procurement.move_id.id])466 move_obj.action_done(cr, uid, [procurement.move_id.id], context=context)
467 res = self.write(cr, uid, ids, {'state': 'done', 'date_close': time.strftime('%Y-%m-%d')})467 res = self.write(cr, uid, ids, {'state': 'done', 'date_close': time.strftime('%Y-%m-%d')})
468 wf_service = netsvc.LocalService("workflow")468 wf_service = netsvc.LocalService("workflow")
469 for id in ids:469 for id in ids:
470 wf_service.trg_trigger(uid, 'procurement.order', id, cr)470 wf_service.trg_trigger(uid, 'procurement.order', id, cr, context=context)
471 return res471 return res
472472
473procurement_order()473procurement_order()
@@ -475,7 +475,7 @@
475class StockPicking(osv.osv):475class StockPicking(osv.osv):
476 _inherit = 'stock.picking'476 _inherit = 'stock.picking'
477477
478 def test_finished(self, cursor, user, ids):478 def test_finished(self, cursor, user, ids, context=None):
479 wf_service = netsvc.LocalService("workflow")479 wf_service = netsvc.LocalService("workflow")
480 res = super(StockPicking, self).test_finished(cursor, user, ids)480 res = super(StockPicking, self).test_finished(cursor, user, ids)
481 for picking in self.browse(cursor, user, ids):481 for picking in self.browse(cursor, user, ids):
@@ -483,7 +483,7 @@
483 if move.state == 'done' and move.procurements:483 if move.state == 'done' and move.procurements:
484 for procurement in move.procurements:484 for procurement in move.procurements:
485 wf_service.trg_validate(user, 'procurement.order',485 wf_service.trg_validate(user, 'procurement.order',
486 procurement.id, 'button_check', cursor)486 procurement.id, 'button_check', cursor, context=context)
487 return res487 return res
488488
489StockPicking()489StockPicking()
490490
=== modified file 'purchase/purchase.py'
--- purchase/purchase.py 2011-12-01 21:32:12 +0000
+++ purchase/purchase.py 2011-12-13 18:03:48 +0000
@@ -339,15 +339,15 @@
339 'account_analytic_id': order_line.account_analytic_id.id or False,339 'account_analytic_id': order_line.account_analytic_id.id or False,
340 }340 }
341341
342 def action_cancel_draft(self, cr, uid, ids, *args):342 def action_cancel_draft(self, cr, uid, ids, context=None):
343 if not len(ids):343 if not len(ids):
344 return False344 return False
345 self.write(cr, uid, ids, {'state':'draft','shipped':0})345 self.write(cr, uid, ids, {'state':'draft','shipped':0})
346 wf_service = netsvc.LocalService("workflow")346 wf_service = netsvc.LocalService("workflow")
347 for p_id in ids:347 for p_id in ids:
348 # Deleting the existing instance of workflow for PO348 # Deleting the existing instance of workflow for PO
349 wf_service.trg_delete(uid, 'purchase.order', p_id, cr)349 wf_service.trg_delete(uid, 'purchase.order', p_id, cr, context=context)
350 wf_service.trg_create(uid, 'purchase.order', p_id, cr)350 wf_service.trg_create(uid, 'purchase.order', p_id, cr, context=context)
351 for (id,name) in self.name_get(cr, uid, ids):351 for (id,name) in self.name_get(cr, uid, ids):
352 message = _("Purchase order '%s' has been set in draft state.") % name352 message = _("Purchase order '%s' has been set in draft state.") % name
353 self.log(cr, uid, id, message)353 self.log(cr, uid, id, message)
@@ -421,7 +421,7 @@
421 res = inv_id421 res = inv_id
422 return res422 return res
423423
424 def has_stockable_product(self,cr, uid, ids, *args):424 def has_stockable_product(self,cr, uid, ids, context=None):
425 for order in self.browse(cr, uid, ids):425 for order in self.browse(cr, uid, ids):
426 for order_line in order.order_line:426 for order_line in order.order_line:
427 if order_line.product_id and order_line.product_id.product_tmpl_id.type in ('product', 'consu'):427 if order_line.product_id and order_line.product_id.product_tmpl_id.type in ('product', 'consu'):
@@ -437,14 +437,14 @@
437 _('Unable to cancel this purchase order!'),437 _('Unable to cancel this purchase order!'),
438 _('You must first cancel all receptions related to this purchase order.'))438 _('You must first cancel all receptions related to this purchase order.'))
439 for pick in purchase.picking_ids:439 for pick in purchase.picking_ids:
440 wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_cancel', cr)440 wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_cancel', cr, context=context)
441 for inv in purchase.invoice_ids:441 for inv in purchase.invoice_ids:
442 if inv and inv.state not in ('cancel','draft'):442 if inv and inv.state not in ('cancel','draft'):
443 raise osv.except_osv(443 raise osv.except_osv(
444 _('Unable to cancel this purchase order!'),444 _('Unable to cancel this purchase order!'),
445 _('You must first cancel all invoices related to this purchase order.'))445 _('You must first cancel all invoices related to this purchase order.'))
446 if inv:446 if inv:
447 wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_cancel', cr)447 wf_service.trg_validate(uid, 'account.invoice', inv.id, 'invoice_cancel', cr, context=context)
448 self.write(cr,uid,ids,{'state':'cancel'})448 self.write(cr,uid,ids,{'state':'cancel'})
449 449
450 for (id, name) in self.name_get(cr, uid, ids):450 for (id, name) in self.name_get(cr, uid, ids):
@@ -453,7 +453,7 @@
453 self.log(cr, uid, id, message)453 self.log(cr, uid, id, message)
454 return True454 return True
455455
456 def _prepare_order_picking(self, cr, uid, order, *args):456 def _prepare_order_picking(self, cr, uid, order, context=None):
457 return {457 return {
458 'name': self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.in'),458 'name': self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.in'),
459 'origin': order.name + ((order.origin and (':' + order.origin)) or ''),459 'origin': order.name + ((order.origin and (':' + order.origin)) or ''),
@@ -466,7 +466,7 @@
466 'move_lines' : [],466 'move_lines' : [],
467 }467 }
468 468
469 def _prepare_order_line_move(self, cr, uid, order, order_line, picking_id, *args):469 def _prepare_order_line_move(self, cr, uid, order, order_line, picking_id, context=None):
470 return {470 return {
471 'name': order.name + ': ' + (order_line.name or ''),471 'name': order.name + ': ' + (order_line.name or ''),
472 'product_id': order_line.product_id.id,472 'product_id': order_line.product_id.id,
@@ -487,7 +487,7 @@
487 'price_unit': order_line.price_unit487 'price_unit': order_line.price_unit
488 }488 }
489489
490 def _create_pickings(self, cr, uid, order, order_lines, picking_id=False, *args):490 def _create_pickings(self, cr, uid, order, order_lines, picking_id=False, context=None):
491 """Creates pickings and appropriate stock moves for given order lines, then491 """Creates pickings and appropriate stock moves for given order lines, then
492 confirms the moves, makes them available, and confirms the picking.492 confirms the moves, makes them available, and confirms the picking.
493493
@@ -507,7 +507,7 @@
507 :return: list of IDs of pickings used/created for the given order lines (usually just one)507 :return: list of IDs of pickings used/created for the given order lines (usually just one)
508 """508 """
509 if not picking_id: 509 if not picking_id:
510 picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, *args))510 picking_id = self.pool.get('stock.picking').create(cr, uid, self._prepare_order_picking(cr, uid, order, context=context))
511 todo_moves = []511 todo_moves = []
512 stock_move = self.pool.get('stock.move')512 stock_move = self.pool.get('stock.move')
513 wf_service = netsvc.LocalService("workflow")513 wf_service = netsvc.LocalService("workflow")
@@ -515,19 +515,19 @@
515 if not order_line.product_id:515 if not order_line.product_id:
516 continue516 continue
517 if order_line.product_id.type in ('product', 'consu'):517 if order_line.product_id.type in ('product', 'consu'):
518 move = stock_move.create(cr, uid, self._prepare_order_line_move(cr, uid, order, order_line, picking_id, *args))518 move = stock_move.create(cr, uid, self._prepare_order_line_move(cr, uid, order, order_line, picking_id, context=context))
519 if order_line.move_dest_id:519 if order_line.move_dest_id:
520 order_line.move_dest_id.write({'location_id': order.location_id.id})520 order_line.move_dest_id.write({'location_id': order.location_id.id})
521 todo_moves.append(move)521 todo_moves.append(move)
522 stock_move.action_confirm(cr, uid, todo_moves)522 stock_move.action_confirm(cr, uid, todo_moves, context=context)
523 stock_move.force_assign(cr, uid, todo_moves)523 stock_move.force_assign(cr, uid, todo_moves, context=context)
524 wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)524 wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr, context=context)
525 return [picking_id]525 return [picking_id]
526526
527 def action_picking_create(self,cr, uid, ids, *args):527 def action_picking_create(self,cr, uid, ids, context=None):
528 picking_ids = []528 picking_ids = []
529 for order in self.browse(cr, uid, ids):529 for order in self.browse(cr, uid, ids):
530 picking_ids.extend(self._create_pickings(cr, uid, order, order.order_line, None, *args))530 picking_ids.extend(self._create_pickings(cr, uid, order, order.order_line, None, context=None))
531531
532 # Must return one unique picking ID: the one to connect in the subflow of the purchase order.532 # Must return one unique picking ID: the one to connect in the subflow of the purchase order.
533 # In case of multiple (split) pickings, we should return the ID of the critical one, i.e. the533 # In case of multiple (split) pickings, we should return the ID of the critical one, i.e. the
@@ -730,7 +730,7 @@
730 # - split into small internal methods for clearity 730 # - split into small internal methods for clearity
731 def product_id_change(self, cr, uid, ids, pricelist, product, qty, uom,731 def product_id_change(self, cr, uid, ids, pricelist, product, qty, uom,
732 partner_id, date_order=False, fiscal_position=False, date_planned=False,732 partner_id, date_order=False, fiscal_position=False, date_planned=False,
733 name=False, price_unit=False, notes=False, context={}):733 name=False, price_unit=False, notes=False, context=None):
734 if not pricelist:734 if not pricelist:
735 raise osv.except_osv(_('No Pricelist !'), _('You have to select a pricelist or a supplier in the purchase form !\nPlease set one before choosing a product.'))735 raise osv.except_osv(_('No Pricelist !'), _('You have to select a pricelist or a supplier in the purchase form !\nPlease set one before choosing a product.'))
736 if not partner_id:736 if not partner_id:
@@ -744,8 +744,9 @@
744 lang=False744 lang=False
745 if partner_id:745 if partner_id:
746 lang=self.pool.get('res.partner').read(cr, uid, partner_id, ['lang'])['lang']746 lang=self.pool.get('res.partner').read(cr, uid, partner_id, ['lang'])['lang']
747 context={'lang':lang}747 if context is None:
748 context['partner_id'] = partner_id748 context = {}
749 context = dict(context, lang=lang, partner_id=partner_id)
749750
750 prod = self.pool.get('product.product').browse(cr, uid, product, context=context)751 prod = self.pool.get('product.product').browse(cr, uid, product, context=context)
751 prod_uom_po = prod.uom_po_id.id752 prod_uom_po = prod.uom_po_id.id
@@ -805,7 +806,7 @@
805 # - merge into 'product_id_change' method806 # - merge into 'product_id_change' method
806 def product_uom_change(self, cr, uid, ids, pricelist, product, qty, uom,807 def product_uom_change(self, cr, uid, ids, pricelist, product, qty, uom,
807 partner_id, date_order=False, fiscal_position=False, date_planned=False,808 partner_id, date_order=False, fiscal_position=False, date_planned=False,
808 name=False, price_unit=False, notes=False, context={}):809 name=False, price_unit=False, notes=False, context=None):
809 res = self.product_id_change(cr, uid, ids, pricelist, product, qty, uom,810 res = self.product_id_change(cr, uid, ids, pricelist, product, qty, uom,
810 partner_id, date_order=date_order, fiscal_position=fiscal_position, date_planned=date_planned,811 partner_id, date_order=date_order, fiscal_position=fiscal_position, date_planned=date_planned,
811 name=name, price_unit=price_unit, notes=notes, context=context)812 name=name, price_unit=price_unit, notes=notes, context=context)
812813
=== modified file 'sale/sale.py'
--- sale/sale.py 2011-12-11 11:09:56 +0000
+++ sale/sale.py 2011-12-13 18:03:48 +0000
@@ -306,7 +306,7 @@
306 v['pricelist_id'] = shop.pricelist_id.id306 v['pricelist_id'] = shop.pricelist_id.id
307 return {'value': v}307 return {'value': v}
308308
309 def action_cancel_draft(self, cr, uid, ids, *args):309 def action_cancel_draft(self, cr, uid, ids, context=None):
310 if not len(ids):310 if not len(ids):
311 return False311 return False
312 cr.execute('select id from sale_order_line where order_id IN %s and state=%s', (tuple(ids), 'cancel'))312 cr.execute('select id from sale_order_line where order_id IN %s and state=%s', (tuple(ids), 'cancel'))
@@ -316,14 +316,14 @@
316 wf_service = netsvc.LocalService("workflow")316 wf_service = netsvc.LocalService("workflow")
317 for inv_id in ids:317 for inv_id in ids:
318 # Deleting the existing instance of workflow for SO318 # Deleting the existing instance of workflow for SO
319 wf_service.trg_delete(uid, 'sale.order', inv_id, cr)319 wf_service.trg_delete(uid, 'sale.order', inv_id, cr, context=context)
320 wf_service.trg_create(uid, 'sale.order', inv_id, cr)320 wf_service.trg_create(uid, 'sale.order', inv_id, cr, context=context)
321 for (id,name) in self.name_get(cr, uid, ids):321 for (id,name) in self.name_get(cr, uid, ids):
322 message = _("The sales order '%s' has been set in draft state.") %(name,)322 message = _("The sales order '%s' has been set in draft state.") %(name,)
323 self.log(cr, uid, id, message)323 self.log(cr, uid, id, message)
324 return True324 return True
325325
326 def onchange_pricelist_id(self, cr, uid, ids, pricelist_id, order_lines, context={}):326 def onchange_pricelist_id(self, cr, uid, ids, pricelist_id, order_lines, context=None):
327 print order_lines327 print order_lines
328 if (not pricelist_id) or (not order_lines):328 if (not pricelist_id) or (not order_lines):
329 return {}329 return {}
@@ -333,6 +333,7 @@
333 }333 }
334 return {'warning': warning}334 return {'warning': warning}
335335
336<<<<<<< TREE
336 def onchange_partner_order_id(self, cr, uid, ids, order_id, invoice_id=False, shipping_id=False, context={}):337 def onchange_partner_order_id(self, cr, uid, ids, order_id, invoice_id=False, shipping_id=False, context={}):
337 if not order_id:338 if not order_id:
338 return {}339 return {}
@@ -344,6 +345,9 @@
344 return {'value': val}345 return {'value': val}
345346
346 def onchange_partner_id(self, cr, uid, ids, part):347 def onchange_partner_id(self, cr, uid, ids, part):
348=======
349 def onchange_partner_id(self, cr, uid, ids, part, context=None):
350>>>>>>> MERGE-SOURCE
347 if not part:351 if not part:
348 return {'value': {'partner_invoice_id': False, 'partner_shipping_id': False, 'partner_order_id': False, 'payment_term': False, 'fiscal_position': False}}352 return {'value': {'partner_invoice_id': False, 'partner_shipping_id': False, 'partner_order_id': False, 'payment_term': False, 'fiscal_position': False}}
349353
@@ -608,7 +612,7 @@
608 proc_ids = proc_obj.search(cr, uid, [('move_id', '=', mov.id)])612 proc_ids = proc_obj.search(cr, uid, [('move_id', '=', mov.id)])
609 if proc_ids:613 if proc_ids:
610 for proc in proc_ids:614 for proc in proc_ids:
611 wf_service.trg_validate(uid, 'procurement.order', proc, 'button_check', cr)615 wf_service.trg_validate(uid, 'procurement.order', proc, 'button_check', cr, context=context)
612 for r in self.read(cr, uid, ids, ['picking_ids']):616 for r in self.read(cr, uid, ids, ['picking_ids']):
613 for pick in r['picking_ids']:617 for pick in r['picking_ids']:
614 wf_service.trg_validate(uid, 'stock.picking', pick, 'button_cancel', cr)618 wf_service.trg_validate(uid, 'stock.picking', pick, 'button_cancel', cr)
@@ -619,7 +623,7 @@
619 _('You must first cancel all invoices attached to this sales order.'))623 _('You must first cancel all invoices attached to this sales order.'))
620 for r in self.read(cr, uid, ids, ['invoice_ids']):624 for r in self.read(cr, uid, ids, ['invoice_ids']):
621 for inv in r['invoice_ids']:625 for inv in r['invoice_ids']:
622 wf_service.trg_validate(uid, 'account.invoice', inv, 'invoice_cancel', cr)626 wf_service.trg_validate(uid, 'account.invoice', inv, 'invoice_cancel', cr, context=context)
623 sale_order_line_obj.write(cr, uid, [l.id for l in sale.order_line],627 sale_order_line_obj.write(cr, uid, [l.id for l in sale.order_line],
624 {'state': 'cancel'})628 {'state': 'cancel'})
625 message = _("The sales order '%s' has been cancelled.") % (sale.name,)629 message = _("The sales order '%s' has been cancelled.") % (sale.name,)
@@ -627,7 +631,7 @@
627 self.write(cr, uid, ids, {'state': 'cancel'})631 self.write(cr, uid, ids, {'state': 'cancel'})
628 return True632 return True
629633
630 def action_wait(self, cr, uid, ids, *args):634 def action_wait(self, cr, uid, ids, context=None):
631 for o in self.browse(cr, uid, ids):635 for o in self.browse(cr, uid, ids):
632 if not o.order_line:636 if not o.order_line:
633 raise osv.except_osv(_('Error !'),_('You cannot confirm a sale order which has no line.'))637 raise osv.except_osv(_('Error !'),_('You cannot confirm a sale order which has no line.'))
@@ -635,12 +639,12 @@
635 self.write(cr, uid, [o.id], {'state': 'manual', 'date_confirm': time.strftime(DEFAULT_SERVER_DATE_FORMAT)})639 self.write(cr, uid, [o.id], {'state': 'manual', 'date_confirm': time.strftime(DEFAULT_SERVER_DATE_FORMAT)})
636 else:640 else:
637 self.write(cr, uid, [o.id], {'state': 'progress', 'date_confirm': time.strftime(DEFAULT_SERVER_DATE_FORMAT)})641 self.write(cr, uid, [o.id], {'state': 'progress', 'date_confirm': time.strftime(DEFAULT_SERVER_DATE_FORMAT)})
638 self.pool.get('sale.order.line').button_confirm(cr, uid, [x.id for x in o.order_line])642 self.pool.get('sale.order.line').button_confirm(cr, uid, [x.id for x in o.order_line], context=context)
639 message = _("The quotation '%s' has been converted to a sales order.") % (o.name,)643 message = _("The quotation '%s' has been converted to a sales order.") % (o.name,)
640 self.log(cr, uid, o.id, message)644 self.log(cr, uid, o.id, message)
641 return True645 return True
642646
643 def procurement_lines_get(self, cr, uid, ids, *args):647 def procurement_lines_get(self, cr, uid, ids, context=None):
644 res = []648 res = []
645 for order in self.browse(cr, uid, ids, context={}):649 for order in self.browse(cr, uid, ids, context={}):
646 for line in order.order_line:650 for line in order.order_line:
@@ -652,14 +656,14 @@
652 # returns True if all lines are done, False otherwise656 # returns True if all lines are done, False otherwise
653 # if mode == 'canceled':657 # if mode == 'canceled':
654 # returns True if there is at least one canceled line, False otherwise658 # returns True if there is at least one canceled line, False otherwise
655 def test_state(self, cr, uid, ids, mode, *args):659 def test_state(self, cr, uid, ids, mode, context=None):
656 assert mode in ('finished', 'canceled'), _("invalid mode for test_state")660 assert mode in ('finished', 'canceled'), _("invalid mode for test_state")
657 finished = True661 finished = True
658 canceled = False662 canceled = False
659 notcanceled = False663 notcanceled = False
660 write_done_ids = []664 write_done_ids = []
661 write_cancel_ids = []665 write_cancel_ids = []
662 for order in self.browse(cr, uid, ids, context={}):666 for order in self.browse(cr, uid, ids, context=context):
663 for line in order.order_line:667 for line in order.order_line:
664 if (not line.procurement_id) or (line.procurement_id.state=='done'):668 if (not line.procurement_id) or (line.procurement_id.state=='done'):
665 if line.state != 'done':669 if line.state != 'done':
@@ -686,7 +690,7 @@
686 return False690 return False
687 return canceled691 return canceled
688692
689 def _prepare_order_line_procurement(self, cr, uid, order, line, move_id, date_planned, *args):693 def _prepare_order_line_procurement(self, cr, uid, order, line, move_id, date_planned, context=None):
690 return {694 return {
691 'name': line.name,695 'name': line.name,
692 'origin': order.name,696 'origin': order.name,
@@ -707,7 +711,7 @@
707 'company_id': order.company_id.id,711 'company_id': order.company_id.id,
708 }712 }
709713
710 def _prepare_order_line_move(self, cr, uid, order, line, picking_id, date_planned, *args):714 def _prepare_order_line_move(self, cr, uid, order, line, picking_id, date_planned, context=None):
711 location_id = order.shop_id.warehouse_id.lot_stock_id.id715 location_id = order.shop_id.warehouse_id.lot_stock_id.id
712 output_id = order.shop_id.warehouse_id.lot_output_id.id716 output_id = order.shop_id.warehouse_id.lot_output_id.id
713 return {717 return {
@@ -734,7 +738,7 @@
734 'price_unit': line.product_id.standard_price or 0.0738 'price_unit': line.product_id.standard_price or 0.0
735 }739 }
736740
737 def _prepare_order_picking(self, cr, uid, order, *args):741 def _prepare_order_picking(self, cr, uid, order, context=None):
738 pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.out')742 pick_name = self.pool.get('ir.sequence').get(cr, uid, 'stock.picking.out')
739 return {743 return {
740 'name': pick_name,744 'name': pick_name,
@@ -750,7 +754,7 @@
750 'company_id': order.company_id.id,754 'company_id': order.company_id.id,
751 }755 }
752756
753 def _create_pickings_and_procurements(self, cr, uid, order, order_lines, picking_id=False, *args):757 def _create_pickings_and_procurements(self, cr, uid, order, order_lines, picking_id=False, context=None):
754 """Create the required procurements to supply sale order lines, also connecting758 """Create the required procurements to supply sale order lines, also connecting
755 the procurements to appropriate stock moves in order to bring the goods to the759 the procurements to appropriate stock moves in order to bring the goods to the
756 sale order's requested location.760 sale order's requested location.
@@ -784,13 +788,13 @@
784 if line.product_id:788 if line.product_id:
785 if line.product_id.product_tmpl_id.type in ('product', 'consu'):789 if line.product_id.product_tmpl_id.type in ('product', 'consu'):
786 if not picking_id:790 if not picking_id:
787 picking_id = picking_obj.create(cr, uid, self._prepare_order_picking(cr, uid, order, *args))791 picking_id = picking_obj.create(cr, uid, self._prepare_order_picking(cr, uid, order, context=context))
788 move_id = move_obj.create(cr, uid, self._prepare_order_line_move(cr, uid, order, line, picking_id, date_planned, *args))792 move_id = move_obj.create(cr, uid, self._prepare_order_line_move(cr, uid, order, line, picking_id, date_planned, context=context))
789 else:793 else:
790 # a service has no stock move794 # a service has no stock move
791 move_id = False795 move_id = False
792796
793 proc_id = procurement_obj.create(cr, uid, self._prepare_order_line_procurement(cr, uid, order, line, move_id, date_planned, *args))797 proc_id = procurement_obj.create(cr, uid, self._prepare_order_line_procurement(cr, uid, order, line, move_id, date_planned, context=context))
794 proc_ids.append(proc_id)798 proc_ids.append(proc_id)
795 line.write({'procurement_id': proc_id})799 line.write({'procurement_id': proc_id})
796800
@@ -809,10 +813,10 @@
809813
810 wf_service = netsvc.LocalService("workflow")814 wf_service = netsvc.LocalService("workflow")
811 if picking_id:815 if picking_id:
812 wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)816 wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr, context=context)
813817
814 for proc_id in proc_ids:818 for proc_id in proc_ids:
815 wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr)819 wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr, context=context)
816820
817 val = {}821 val = {}
818 if order.state == 'shipping_except':822 if order.state == 'shipping_except':
@@ -827,9 +831,9 @@
827 order.write(val)831 order.write(val)
828 return True832 return True
829833
830 def action_ship_create(self, cr, uid, ids, *args):834 def action_ship_create(self, cr, uid, ids, context=None):
831 for order in self.browse(cr, uid, ids, context={}):835 for order in self.browse(cr, uid, ids, context=context):
832 self._create_pickings_and_procurements(cr, uid, order, order.order_line, None, *args)836 self._create_pickings_and_procurements(cr, uid, order, order.order_line, None, context=context)
833 return True837 return True
834838
835 def action_ship_end(self, cr, uid, ids, context=None):839 def action_ship_end(self, cr, uid, ids, context=None):
@@ -1041,7 +1045,7 @@
1041 # Trigger workflow events1045 # Trigger workflow events
1042 wf_service = netsvc.LocalService("workflow")1046 wf_service = netsvc.LocalService("workflow")
1043 for sid in sales.keys():1047 for sid in sales.keys():
1044 wf_service.trg_write(uid, 'sale.order', sid, cr)1048 wf_service.trg_write(uid, 'sale.order', sid, cr, context=context)
1045 return create_ids1049 return create_ids
10461050
1047 def button_cancel(self, cr, uid, ids, context=None):1051 def button_cancel(self, cr, uid, ids, context=None):
@@ -1065,7 +1069,7 @@
1065 wf_service.trg_write(uid, 'sale.order', line.order_id.id, cr)1069 wf_service.trg_write(uid, 'sale.order', line.order_id.id, cr)
1066 return res1070 return res
10671071
1068 def uos_change(self, cr, uid, ids, product_uos, product_uos_qty=0, product_id=None):1072 def uos_change(self, cr, uid, ids, product_uos, product_uos_qty=0, product_id=None, context=None):
1069 product_obj = self.pool.get('product.product')1073 product_obj = self.pool.get('product.product')
1070 if not product_id:1074 if not product_id:
1071 return {'value': {'product_uom': product_uos,1075 return {'value': {'product_uom': product_uos,
10721076
=== modified file 'stock/stock.py'
--- stock/stock.py 2011-12-01 21:32:12 +0000
+++ stock/stock.py 2011-12-13 18:03:48 +0000
@@ -739,7 +739,7 @@
739 # TODO: Check locations to see if in the same location ?739 # TODO: Check locations to see if in the same location ?
740 return True740 return True
741741
742 def action_assign(self, cr, uid, ids, *args):742 def action_assign(self, cr, uid, ids, context=None):
743 """ Changes state of picking to available if all moves are confirmed.743 """ Changes state of picking to available if all moves are confirmed.
744 @return: True744 @return: True
745 """745 """
@@ -750,7 +750,7 @@
750 self.pool.get('stock.move').action_assign(cr, uid, move_ids)750 self.pool.get('stock.move').action_assign(cr, uid, move_ids)
751 return True751 return True
752752
753 def force_assign(self, cr, uid, ids, *args):753 def force_assign(self, cr, uid, ids, context=None):
754 """ Changes state of picking to available if moves are confirmed or waiting.754 """ Changes state of picking to available if moves are confirmed or waiting.
755 @return: True755 @return: True
756 """756 """
@@ -758,10 +758,10 @@
758 for pick in self.browse(cr, uid, ids):758 for pick in self.browse(cr, uid, ids):
759 move_ids = [x.id for x in pick.move_lines if x.state in ['confirmed','waiting']]759 move_ids = [x.id for x in pick.move_lines if x.state in ['confirmed','waiting']]
760 self.pool.get('stock.move').force_assign(cr, uid, move_ids)760 self.pool.get('stock.move').force_assign(cr, uid, move_ids)
761 wf_service.trg_write(uid, 'stock.picking', pick.id, cr)761 wf_service.trg_write(uid, 'stock.picking', pick.id, cr, context=context)
762 return True762 return True
763763
764 def draft_force_assign(self, cr, uid, ids, *args):764 def draft_force_assign(self, cr, uid, ids, context=None):
765 """ Confirms picking directly from draft state.765 """ Confirms picking directly from draft state.
766 @return: True766 @return: True
767 """767 """
@@ -770,7 +770,7 @@
770 if not pick.move_lines:770 if not pick.move_lines:
771 raise osv.except_osv(_('Error !'),_('You can not process picking without stock moves'))771 raise osv.except_osv(_('Error !'),_('You can not process picking without stock moves'))
772 wf_service.trg_validate(uid, 'stock.picking', pick.id,772 wf_service.trg_validate(uid, 'stock.picking', pick.id,
773 'button_confirm', cr)773 'button_confirm', cr, context=context)
774 return True774 return True
775775
776 def draft_validate(self, cr, uid, ids, context=None):776 def draft_validate(self, cr, uid, ids, context=None):
@@ -782,10 +782,10 @@
782 for pick in self.browse(cr, uid, ids, context=context):782 for pick in self.browse(cr, uid, ids, context=context):
783 move_ids = [x.id for x in pick.move_lines]783 move_ids = [x.id for x in pick.move_lines]
784 self.pool.get('stock.move').force_assign(cr, uid, move_ids)784 self.pool.get('stock.move').force_assign(cr, uid, move_ids)
785 wf_service.trg_write(uid, 'stock.picking', pick.id, cr)785 wf_service.trg_write(uid, 'stock.picking', pick.id, cr, context=context)
786 return self.action_process(786 return self.action_process(
787 cr, uid, ids, context=context)787 cr, uid, ids, context=context)
788 def cancel_assign(self, cr, uid, ids, *args):788 def cancel_assign(self, cr, uid, ids, context=None):
789 """ Cancels picking and moves.789 """ Cancels picking and moves.
790 @return: True790 @return: True
791 """791 """
@@ -793,7 +793,7 @@
793 for pick in self.browse(cr, uid, ids):793 for pick in self.browse(cr, uid, ids):
794 move_ids = [x.id for x in pick.move_lines]794 move_ids = [x.id for x in pick.move_lines]
795 self.pool.get('stock.move').cancel_assign(cr, uid, move_ids)795 self.pool.get('stock.move').cancel_assign(cr, uid, move_ids)
796 wf_service.trg_write(uid, 'stock.picking', pick.id, cr)796 wf_service.trg_write(uid, 'stock.picking', pick.id, cr, context=context)
797 return True797 return True
798798
799 def action_assign_wkf(self, cr, uid, ids, context=None):799 def action_assign_wkf(self, cr, uid, ids, context=None):
@@ -804,7 +804,7 @@
804 self.log_picking(cr, uid, ids, context=context)804 self.log_picking(cr, uid, ids, context=context)
805 return True805 return True
806806
807 def test_finished(self, cr, uid, ids):807 def test_finished(self, cr, uid, ids, context=None):
808 """ Tests whether the move is in done or cancel state or not.808 """ Tests whether the move is in done or cancel state or not.
809 @return: True or False809 @return: True or False
810 """810 """
@@ -818,7 +818,7 @@
818 move.write({'state': 'done'})818 move.write({'state': 'done'})
819 return True819 return True
820820
821 def test_assigned(self, cr, uid, ids):821 def test_assigned(self, cr, uid, ids, context=None):
822 """ Tests whether the move is in assigned state or not.822 """ Tests whether the move is in assigned state or not.
823 @return: True or False823 @return: True or False
824 """824 """
@@ -1284,16 +1284,16 @@
12841284
1285 # At first we confirm the new picking (if necessary)1285 # At first we confirm the new picking (if necessary)
1286 if new_picking:1286 if new_picking:
1287 wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr)1287 wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_confirm', cr, context=context)
1288 # Then we finish the good picking1288 # Then we finish the good picking
1289 self.write(cr, uid, [pick.id], {'backorder_id': new_picking})1289 self.write(cr, uid, [pick.id], {'backorder_id': new_picking})
1290 self.action_move(cr, uid, [new_picking])1290 self.action_move(cr, uid, [new_picking], context=context)
1291 wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_done', cr)1291 wf_service.trg_validate(uid, 'stock.picking', new_picking, 'button_done', cr, context=context)
1292 wf_service.trg_write(uid, 'stock.picking', pick.id, cr)1292 wf_service.trg_write(uid, 'stock.picking', pick.id, cr, context=context)
1293 delivered_pack_id = new_picking1293 delivered_pack_id = new_picking
1294 else:1294 else:
1295 self.action_move(cr, uid, [pick.id])1295 self.action_move(cr, uid, [pick.id])
1296 wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_done', cr)1296 wf_service.trg_validate(uid, 'stock.picking', pick.id, 'button_done', cr, context=context)
1297 delivered_pack_id = pick.id1297 delivered_pack_id = pick.id
12981298
1299 delivered_pack = self.browse(cr, uid, delivered_pack_id, context=context)1299 delivered_pack = self.browse(cr, uid, delivered_pack_id, context=context)
@@ -1909,7 +1909,7 @@
1909 })1909 })
1910 new_moves.append(self.browse(cr, uid, [new_id])[0])1910 new_moves.append(self.browse(cr, uid, [new_id])[0])
1911 if pickid:1911 if pickid:
1912 wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr)1912 wf_service.trg_validate(uid, 'stock.picking', pickid, 'button_confirm', cr, context=context)
1913 if new_moves:1913 if new_moves:
1914 new_moves += self.create_chained_picking(cr, uid, new_moves, context)1914 new_moves += self.create_chained_picking(cr, uid, new_moves, context)
1915 return new_moves1915 return new_moves
@@ -1920,10 +1920,10 @@
1920 """1920 """
1921 moves = self.browse(cr, uid, ids, context=context)1921 moves = self.browse(cr, uid, ids, context=context)
1922 self.write(cr, uid, ids, {'state': 'confirmed'})1922 self.write(cr, uid, ids, {'state': 'confirmed'})
1923 self.create_chained_picking(cr, uid, moves, context)1923 self.create_chained_picking(cr, uid, moves, context=context)
1924 return []1924 return []
19251925
1926 def action_assign(self, cr, uid, ids, *args):1926 def action_assign(self, cr, uid, ids, context=None):
1927 """ Changes state to confirmed or waiting.1927 """ Changes state to confirmed or waiting.
1928 @return: List of values1928 @return: List of values
1929 """1929 """
@@ -1931,7 +1931,7 @@
1931 for move in self.browse(cr, uid, ids):1931 for move in self.browse(cr, uid, ids):
1932 if move.state in ('confirmed', 'waiting'):1932 if move.state in ('confirmed', 'waiting'):
1933 todo.append(move.id)1933 todo.append(move.id)
1934 res = self.check_assign(cr, uid, todo)1934 res = self.check_assign(cr, uid, todo, context=context)
1935 return res1935 return res
19361936
1937 def force_assign(self, cr, uid, ids, context=None):1937 def force_assign(self, cr, uid, ids, context=None):
@@ -2203,10 +2203,10 @@
22032203
2204 self.write(cr, uid, move_ids, {'state': 'done', 'date': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)2204 self.write(cr, uid, move_ids, {'state': 'done', 'date': time.strftime('%Y-%m-%d %H:%M:%S')}, context=context)
2205 for id in move_ids:2205 for id in move_ids:
2206 wf_service.trg_trigger(uid, 'stock.move', id, cr)2206 wf_service.trg_trigger(uid, 'stock.move', id, cr, context=context)
22072207
2208 for pick_id in picking_ids:2208 for pick_id in picking_ids:
2209 wf_service.trg_write(uid, 'stock.picking', pick_id, cr)2209 wf_service.trg_write(uid, 'stock.picking', pick_id, cr, context=context)
22102210
2211 return True2211 return True
22122212
22132213
=== modified file 'stock_location/procurement_pull.py'
--- stock_location/procurement_pull.py 2011-11-24 15:50:58 +0000
+++ stock_location/procurement_pull.py 2011-12-13 18:03:48 +0000
@@ -45,7 +45,7 @@
45 return (line.type_proc=='move') and (line.location_src_id)45 return (line.type_proc=='move') and (line.location_src_id)
46 return False46 return False
4747
48 def action_move_create(self, cr, uid, ids,context=None):48 def action_move_create(self, cr, uid, ids, context=None):
49 proc_obj = self.pool.get('procurement.order')49 proc_obj = self.pool.get('procurement.order')
50 move_obj = self.pool.get('stock.move')50 move_obj = self.pool.get('stock.move')
51 picking_obj=self.pool.get('stock.picking')51 picking_obj=self.pool.get('stock.picking')
@@ -110,15 +110,15 @@
110 'move_id': move_id,110 'move_id': move_id,
111 })111 })
112 wf_service = netsvc.LocalService("workflow")112 wf_service = netsvc.LocalService("workflow")
113 wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr)113 wf_service.trg_validate(uid, 'stock.picking', picking_id, 'button_confirm', cr, context=context)
114 wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr)114 wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_confirm', cr, context=context)
115 if proc.move_id:115 if proc.move_id:
116 move_obj.write(cr, uid, [proc.move_id.id],116 move_obj.write(cr, uid, [proc.move_id.id],
117 {'location_id':proc.location_id.id})117 {'location_id':proc.location_id.id})
118 self.write(cr, uid, [proc.id], {'state':'running', 'message':_('Pulled from another location via procurement %d')%proc_id})118 self.write(cr, uid, [proc.id], {'state':'running', 'message':_('Pulled from another location via procurement %d')%proc_id})
119119
120 # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed)120 # trigger direct processing (the new procurement shares the same planned date as the original one, which is already being processed)
121 wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr)121 wf_service.trg_validate(uid, 'procurement.order', proc_id, 'button_check', cr, context=context)
122 return False122 return False
123123
124procurement_order()124procurement_order()

Subscribers

People subscribed via source and target branches

to all changes: