Merge lp:~openerp-dev/openobject-addons/trunk-workflow-context-odo into lp:openobject-addons
- trunk-workflow-context-odo
- Merge into trunk
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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenERP Core Team | Pending | ||
Review via email: mp+85530@code.launchpad.net |
Commit message
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
Unmerged revisions
- 5838. By Olivier Dony (Odoo)
-
[IMP] workflows: accept and propagate context during workflow execution (wip)
Preview Diff
1 | === modified file 'account/account_invoice.py' | |||
2 | --- account/account_invoice.py 2011-12-06 10:13:54 +0000 | |||
3 | +++ account/account_invoice.py 2011-12-13 18:03:48 +0000 | |||
4 | @@ -466,7 +466,7 @@ | |||
5 | 466 | } | 466 | } |
6 | 467 | return result | 467 | return result |
7 | 468 | 468 | ||
9 | 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): |
10 | 470 | if not payment_term_id: | 470 | if not payment_term_id: |
11 | 471 | return {} | 471 | return {} |
12 | 472 | res = {} | 472 | res = {} |
13 | @@ -578,12 +578,12 @@ | |||
14 | 578 | return {'value': val, 'domain': dom} | 578 | return {'value': val, 'domain': dom} |
15 | 579 | 579 | ||
16 | 580 | # go from canceled state to draft state | 580 | # go from canceled state to draft state |
18 | 581 | def action_cancel_draft(self, cr, uid, ids, *args): | 581 | def action_cancel_draft(self, cr, uid, ids, context=None): |
19 | 582 | self.write(cr, uid, ids, {'state':'draft'}) | 582 | self.write(cr, uid, ids, {'state':'draft'}) |
20 | 583 | wf_service = netsvc.LocalService("workflow") | 583 | wf_service = netsvc.LocalService("workflow") |
21 | 584 | for inv_id in ids: | 584 | for inv_id in ids: |
24 | 585 | wf_service.trg_delete(uid, 'account.invoice', inv_id, cr) | 585 | wf_service.trg_delete(uid, 'account.invoice', inv_id, cr, context=context) |
25 | 586 | wf_service.trg_create(uid, 'account.invoice', inv_id, cr) | 586 | wf_service.trg_create(uid, 'account.invoice', inv_id, cr, context=context) |
26 | 587 | return True | 587 | return True |
27 | 588 | 588 | ||
28 | 589 | # Workflow stuff | 589 | # Workflow stuff |
29 | @@ -591,12 +591,12 @@ | |||
30 | 591 | 591 | ||
31 | 592 | # return the ids of the move lines which has the same account than the invoice | 592 | # return the ids of the move lines which has the same account than the invoice |
32 | 593 | # whose id is in ids | 593 | # whose id is in ids |
34 | 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): |
35 | 595 | if not ids: return [] | 595 | if not ids: return [] |
37 | 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) |
38 | 597 | return result.get(ids[0], []) | 597 | return result.get(ids[0], []) |
39 | 598 | 598 | ||
41 | 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): |
42 | 600 | res = {} | 600 | res = {} |
43 | 601 | if not ids: return res | 601 | if not ids: return res |
44 | 602 | cr.execute('SELECT i.id, l.id '\ | 602 | cr.execute('SELECT i.id, l.id '\ |
45 | @@ -630,8 +630,8 @@ | |||
46 | 630 | }) | 630 | }) |
47 | 631 | return super(account_invoice, self).copy(cr, uid, id, default, context) | 631 | return super(account_invoice, self).copy(cr, uid, id, default, context) |
48 | 632 | 632 | ||
51 | 633 | def test_paid(self, cr, uid, ids, *args): | 633 | def test_paid(self, cr, uid, ids, context=None): |
52 | 634 | res = self.move_line_id_payment_get(cr, uid, ids) | 634 | res = self.move_line_id_payment_get(cr, uid, ids, context=context) |
53 | 635 | if not res: | 635 | if not res: |
54 | 636 | return False | 636 | return False |
55 | 637 | ok = True | 637 | ok = True |
56 | @@ -701,14 +701,14 @@ | |||
57 | 701 | })] | 701 | })] |
58 | 702 | return iml | 702 | return iml |
59 | 703 | 703 | ||
61 | 704 | def action_date_assign(self, cr, uid, ids, *args): | 704 | def action_date_assign(self, cr, uid, ids, context=None): |
62 | 705 | for inv in self.browse(cr, uid, ids): | 705 | for inv in self.browse(cr, uid, ids): |
64 | 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) |
65 | 707 | if res and res['value']: | 707 | if res and res['value']: |
66 | 708 | self.write(cr, uid, [inv.id], res['value']) | 708 | self.write(cr, uid, [inv.id], res['value']) |
67 | 709 | return True | 709 | return True |
68 | 710 | 710 | ||
70 | 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): |
71 | 712 | """finalize_invoice_move_lines(cr, uid, invoice, move_lines) -> move_lines | 712 | """finalize_invoice_move_lines(cr, uid, invoice, move_lines) -> move_lines |
72 | 713 | Hook method to be overridden in additional modules to verify and possibly alter the | 713 | Hook method to be overridden in additional modules to verify and possibly alter the |
73 | 714 | move lines to be created by an invoice, for special cases. | 714 | move lines to be created by an invoice, for special cases. |
74 | @@ -794,12 +794,13 @@ | |||
75 | 794 | line.append((0,0,val)) | 794 | line.append((0,0,val)) |
76 | 795 | return line | 795 | return line |
77 | 796 | 796 | ||
79 | 797 | def action_move_create(self, cr, uid, ids, *args): | 797 | def action_move_create(self, cr, uid, ids, context=None): |
80 | 798 | """Creates invoice related analytics and financial move lines""" | 798 | """Creates invoice related analytics and financial move lines""" |
81 | 799 | ait_obj = self.pool.get('account.invoice.tax') | 799 | ait_obj = self.pool.get('account.invoice.tax') |
82 | 800 | cur_obj = self.pool.get('res.currency') | 800 | cur_obj = self.pool.get('res.currency') |
83 | 801 | period_obj = self.pool.get('account.period') | 801 | period_obj = self.pool.get('account.period') |
85 | 802 | context = {} | 802 | if context is None: |
86 | 803 | context = {} | ||
87 | 803 | for inv in self.browse(cr, uid, ids): | 804 | for inv in self.browse(cr, uid, ids): |
88 | 804 | if not inv.journal_id.sequence_id: | 805 | if not inv.journal_id.sequence_id: |
89 | 805 | raise osv.except_osv(_('Error !'), _('Please define sequence on invoice journal')) | 806 | raise osv.except_osv(_('Error !'), _('Please define sequence on invoice journal')) |
90 | @@ -815,8 +816,7 @@ | |||
91 | 815 | # one move line per invoice line | 816 | # one move line per invoice line |
92 | 816 | iml = self._get_analytic_lines(cr, uid, inv.id) | 817 | iml = self._get_analytic_lines(cr, uid, inv.id) |
93 | 817 | # check if taxes are all computed | 818 | # check if taxes are all computed |
96 | 818 | ctx = context.copy() | 819 | ctx = dict(context, lang=inv.partner_id.lang) |
95 | 819 | ctx.update({'lang': inv.partner_id.lang}) | ||
97 | 820 | compute_taxes = ait_obj.compute(cr, uid, inv.id, context=ctx) | 820 | compute_taxes = ait_obj.compute(cr, uid, inv.id, context=ctx) |
98 | 821 | self.check_tax_lines(cr, uid, inv, compute_taxes, ait_obj) | 821 | self.check_tax_lines(cr, uid, inv, compute_taxes, ait_obj) |
99 | 822 | 822 | ||
100 | @@ -916,7 +916,7 @@ | |||
101 | 916 | raise osv.except_osv(_('UserError'), | 916 | raise osv.except_osv(_('UserError'), |
102 | 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.')) |
103 | 918 | 918 | ||
105 | 919 | line = self.finalize_invoice_move_lines(cr, uid, inv, line) | 919 | line = self.finalize_invoice_move_lines(cr, uid, inv, line, context=context) |
106 | 920 | 920 | ||
107 | 921 | move = { | 921 | move = { |
108 | 922 | 'ref': inv.reference and inv.reference or inv.name, | 922 | 'ref': inv.reference and inv.reference or inv.name, |
109 | @@ -1009,8 +1009,7 @@ | |||
110 | 1009 | self.log(cr, uid, inv_id, message, context=ctx) | 1009 | self.log(cr, uid, inv_id, message, context=ctx) |
111 | 1010 | return True | 1010 | return True |
112 | 1011 | 1011 | ||
115 | 1012 | def action_cancel(self, cr, uid, ids, *args): | 1012 | def action_cancel(self, cr, uid, ids, context=None): |
114 | 1013 | context = {} # TODO: Use context from arguments | ||
116 | 1014 | account_move_obj = self.pool.get('account.move') | 1013 | account_move_obj = self.pool.get('account.move') |
117 | 1015 | invoices = self.read(cr, uid, ids, ['move_id', 'payment_ids']) | 1014 | invoices = self.read(cr, uid, ids, ['move_id', 'payment_ids']) |
118 | 1016 | move_ids = [] # ones that we will need to remove | 1015 | move_ids = [] # ones that we will need to remove |
119 | 1017 | 1016 | ||
120 | === modified file 'hr_expense/hr_expense.py' | |||
121 | --- hr_expense/hr_expense.py 2011-11-28 08:06:57 +0000 | |||
122 | +++ hr_expense/hr_expense.py 2011-12-13 18:03:48 +0000 | |||
123 | @@ -105,14 +105,14 @@ | |||
124 | 105 | company_id = employee.company_id.id | 105 | company_id = employee.company_id.id |
125 | 106 | return {'value': {'department_id': department_id, 'company_id': company_id}} | 106 | return {'value': {'department_id': department_id, 'company_id': company_id}} |
126 | 107 | 107 | ||
128 | 108 | def expense_confirm(self, cr, uid, ids, *args): | 108 | def expense_confirm(self, cr, uid, ids, context=None): |
129 | 109 | self.write(cr, uid, ids, { | 109 | self.write(cr, uid, ids, { |
130 | 110 | 'state':'confirm', | 110 | 'state':'confirm', |
131 | 111 | 'date_confirm': time.strftime('%Y-%m-%d') | 111 | 'date_confirm': time.strftime('%Y-%m-%d') |
132 | 112 | }) | 112 | }) |
133 | 113 | return True | 113 | return True |
134 | 114 | 114 | ||
136 | 115 | def expense_accept(self, cr, uid, ids, *args): | 115 | def expense_accept(self, cr, uid, ids, context=None): |
137 | 116 | self.write(cr, uid, ids, { | 116 | self.write(cr, uid, ids, { |
138 | 117 | 'state':'accepted', | 117 | 'state':'accepted', |
139 | 118 | 'date_valid':time.strftime('%Y-%m-%d'), | 118 | 'date_valid':time.strftime('%Y-%m-%d'), |
140 | @@ -120,11 +120,11 @@ | |||
141 | 120 | }) | 120 | }) |
142 | 121 | return True | 121 | return True |
143 | 122 | 122 | ||
145 | 123 | def expense_canceled(self, cr, uid, ids, *args): | 123 | def expense_canceled(self, cr, uid, ids, context=None): |
146 | 124 | self.write(cr, uid, ids, {'state':'cancelled'}) | 124 | self.write(cr, uid, ids, {'state':'cancelled'}) |
147 | 125 | return True | 125 | return True |
148 | 126 | 126 | ||
150 | 127 | def expense_paid(self, cr, uid, ids, *args): | 127 | def expense_paid(self, cr, uid, ids, context=None): |
151 | 128 | self.write(cr, uid, ids, {'state':'paid'}) | 128 | self.write(cr, uid, ids, {'state':'paid'}) |
152 | 129 | return True | 129 | return True |
153 | 130 | 130 | ||
154 | @@ -149,7 +149,7 @@ | |||
155 | 149 | 'res_id': inv_ids and inv_ids[0] or False, | 149 | 'res_id': inv_ids and inv_ids[0] or False, |
156 | 150 | } | 150 | } |
157 | 151 | 151 | ||
159 | 152 | def action_invoice_create(self, cr, uid, ids): | 152 | def action_invoice_create(self, cr, uid, ids, context=None): |
160 | 153 | res = False | 153 | res = False |
161 | 154 | invoice_obj = self.pool.get('account.invoice') | 154 | invoice_obj = self.pool.get('account.invoice') |
162 | 155 | property_obj = self.pool.get('ir.property') | 155 | property_obj = self.pool.get('ir.property') |
163 | 156 | 156 | ||
164 | === modified file 'hr_payroll/hr_payroll.py' | |||
165 | --- hr_payroll/hr_payroll.py 2011-11-30 14:01:07 +0000 | |||
166 | +++ hr_payroll/hr_payroll.py 2011-12-13 18:03:48 +0000 | |||
167 | @@ -336,8 +336,8 @@ | |||
168 | 336 | for payslip in self.browse(cr, uid, ids, context=context): | 336 | for payslip in self.browse(cr, uid, ids, context=context): |
169 | 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) |
170 | 338 | self.compute_sheet(cr, uid, [id_copy], context=context) | 338 | self.compute_sheet(cr, uid, [id_copy], context=context) |
173 | 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) |
174 | 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) |
175 | 341 | 341 | ||
176 | 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') |
177 | 343 | form_res = form_id and form_id[1] or False | 343 | form_res = form_id and form_id[1] or False |
178 | 344 | 344 | ||
179 | === modified file 'mrp/mrp.py' | |||
180 | --- mrp/mrp.py 2011-12-06 08:12:49 +0000 | |||
181 | +++ mrp/mrp.py 2011-12-13 18:03:48 +0000 | |||
182 | @@ -585,14 +585,14 @@ | |||
183 | 585 | } | 585 | } |
184 | 586 | return {'value': result} | 586 | return {'value': result} |
185 | 587 | 587 | ||
187 | 588 | def action_picking_except(self, cr, uid, ids): | 588 | def action_picking_except(self, cr, uid, ids, context=None): |
188 | 589 | """ Changes the state to Exception. | 589 | """ Changes the state to Exception. |
189 | 590 | @return: True | 590 | @return: True |
190 | 591 | """ | 591 | """ |
191 | 592 | self.write(cr, uid, ids, {'state': 'picking_except'}) | 592 | self.write(cr, uid, ids, {'state': 'picking_except'}) |
192 | 593 | return True | 593 | return True |
193 | 594 | 594 | ||
195 | 595 | def action_compute(self, cr, uid, ids, properties=[]): | 595 | def action_compute(self, cr, uid, ids, properties=[], context=None): |
196 | 596 | """ Computes bills of material of a product. | 596 | """ Computes bills of material of a product. |
197 | 597 | @param properties: List containing dictionaries of properties. | 597 | @param properties: List containing dictionaries of properties. |
198 | 598 | @return: No. of products. | 598 | @return: No. of products. |
199 | @@ -663,15 +663,15 @@ | |||
200 | 663 | self.log(cr, uid, production_id, message) | 663 | self.log(cr, uid, production_id, message) |
201 | 664 | return True | 664 | return True |
202 | 665 | 665 | ||
204 | 666 | def action_production_end(self, cr, uid, ids): | 666 | def action_production_end(self, cr, uid, ids, context=None): |
205 | 667 | """ Changes production state to Finish and writes finished date. | 667 | """ Changes production state to Finish and writes finished date. |
206 | 668 | @return: True | 668 | @return: True |
207 | 669 | """ | 669 | """ |
210 | 670 | for production in self.browse(cr, uid, ids): | 670 | for production in self.browse(cr, uid, ids, context=context): |
211 | 671 | self._costs_generate(cr, uid, production) | 671 | self._costs_generate(cr, uid, production, context=context) |
212 | 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')}) |
213 | 673 | 673 | ||
215 | 674 | def test_production_done(self, cr, uid, ids): | 674 | def test_production_done(self, cr, uid, ids, context=None): |
216 | 675 | """ Tests whether production is done or not. | 675 | """ Tests whether production is done or not. |
217 | 676 | @return: True or False | 676 | @return: True or False |
218 | 677 | """ | 677 | """ |
219 | @@ -791,7 +791,7 @@ | |||
220 | 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) |
221 | 792 | return True | 792 | return True |
222 | 793 | 793 | ||
224 | 794 | def _costs_generate(self, cr, uid, production): | 794 | def _costs_generate(self, cr, uid, production, context=None): |
225 | 795 | """ Calculates total costs at the end of the production. | 795 | """ Calculates total costs at the end of the production. |
226 | 796 | @param production: Id of production order. | 796 | @param production: Id of production order. |
227 | 797 | @return: Calculated amount. | 797 | @return: Calculated amount. |
228 | @@ -834,14 +834,14 @@ | |||
229 | 834 | } ) | 834 | } ) |
230 | 835 | return amount | 835 | return amount |
231 | 836 | 836 | ||
233 | 837 | def action_in_production(self, cr, uid, ids): | 837 | def action_in_production(self, cr, uid, ids, context=None): |
234 | 838 | """ Changes state to In Production and writes starting date. | 838 | """ Changes state to In Production and writes starting date. |
235 | 839 | @return: True | 839 | @return: True |
236 | 840 | """ | 840 | """ |
237 | 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')}) |
238 | 842 | return True | 842 | return True |
239 | 843 | 843 | ||
241 | 844 | def test_if_product(self, cr, uid, ids): | 844 | def test_if_product(self, cr, uid, ids, context=None): |
242 | 845 | """ | 845 | """ |
243 | 846 | @return: True or False | 846 | @return: True or False |
244 | 847 | """ | 847 | """ |
245 | @@ -852,10 +852,10 @@ | |||
246 | 852 | res = False | 852 | res = False |
247 | 853 | return res | 853 | return res |
248 | 854 | 854 | ||
250 | 855 | def _get_auto_picking(self, cr, uid, production): | 855 | def _get_auto_picking(self, cr, uid, production, context=None): |
251 | 856 | return True | 856 | return True |
252 | 857 | 857 | ||
254 | 858 | def action_confirm(self, cr, uid, ids): | 858 | def action_confirm(self, cr, uid, ids, context=None): |
255 | 859 | """ Confirms production order. | 859 | """ Confirms production order. |
256 | 860 | @return: Newly generated picking Id. | 860 | @return: Newly generated picking Id. |
257 | 861 | """ | 861 | """ |
258 | @@ -866,10 +866,10 @@ | |||
259 | 866 | move_obj = self.pool.get('stock.move') | 866 | move_obj = self.pool.get('stock.move') |
260 | 867 | proc_obj = self.pool.get('procurement.order') | 867 | proc_obj = self.pool.get('procurement.order') |
261 | 868 | wf_service = netsvc.LocalService("workflow") | 868 | wf_service = netsvc.LocalService("workflow") |
263 | 869 | for production in self.browse(cr, uid, ids): | 869 | for production in self.browse(cr, uid, ids, context=context): |
264 | 870 | if not production.product_lines: | 870 | if not production.product_lines: |
267 | 871 | self.action_compute(cr, uid, [production.id]) | 871 | self.action_compute(cr, uid, [production.id], context=context) |
268 | 872 | production = self.browse(cr, uid, [production.id])[0] | 872 | production = self.browse(cr, uid, [production.id], context=context)[0] |
269 | 873 | routing_loc = None | 873 | routing_loc = None |
270 | 874 | pick_type = 'internal' | 874 | pick_type = 'internal' |
271 | 875 | address_id = False | 875 | address_id = False |
272 | @@ -958,9 +958,9 @@ | |||
273 | 958 | 'move_id': move_id, | 958 | 'move_id': move_id, |
274 | 959 | 'company_id': production.company_id.id, | 959 | 'company_id': production.company_id.id, |
275 | 960 | }) | 960 | }) |
277 | 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) |
278 | 962 | proc_ids.append(proc_id) | 962 | proc_ids.append(proc_id) |
280 | 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) |
281 | 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'}) |
282 | 965 | message = _("Manufacturing order '%s' is scheduled for the %s.") % ( | 965 | message = _("Manufacturing order '%s' is scheduled for the %s.") % ( |
283 | 966 | production.name, | 966 | production.name, |
284 | @@ -969,13 +969,13 @@ | |||
285 | 969 | self.log(cr, uid, production.id, message) | 969 | self.log(cr, uid, production.id, message) |
286 | 970 | return picking_id | 970 | return picking_id |
287 | 971 | 971 | ||
289 | 972 | def force_production(self, cr, uid, ids, *args): | 972 | def force_production(self, cr, uid, ids, context=None): |
290 | 973 | """ Assigns products. | 973 | """ Assigns products. |
291 | 974 | @param *args: Arguments | 974 | @param *args: Arguments |
292 | 975 | @return: True | 975 | @return: True |
293 | 976 | """ | 976 | """ |
294 | 977 | pick_obj = self.pool.get('stock.picking') | 977 | pick_obj = self.pool.get('stock.picking') |
296 | 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) |
297 | 979 | return True | 979 | return True |
298 | 980 | 980 | ||
299 | 981 | mrp_production() | 981 | mrp_production() |
300 | 982 | 982 | ||
301 | === modified file 'mrp/procurement.py' | |||
302 | --- mrp/procurement.py 2011-09-17 16:41:25 +0000 | |||
303 | +++ mrp/procurement.py 2011-12-13 18:03:48 +0000 | |||
304 | @@ -33,7 +33,7 @@ | |||
305 | 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'), |
306 | 34 | } | 34 | } |
307 | 35 | 35 | ||
309 | 36 | def check_produce_product(self, cr, uid, procurement, context=[]): | 36 | def check_produce_product(self, cr, uid, procurement, context=None): |
310 | 37 | """ Finds the bill of material for the product from procurement order. | 37 | """ Finds the bill of material for the product from procurement order. |
311 | 38 | @return: True or False | 38 | @return: True or False |
312 | 39 | """ | 39 | """ |
313 | @@ -99,7 +99,7 @@ | |||
314 | 99 | self.write(cr, uid, [procurement.id], {'state': 'running'}) | 99 | self.write(cr, uid, [procurement.id], {'state': 'running'}) |
315 | 100 | bom_result = production_obj.action_compute(cr, uid, | 100 | bom_result = production_obj.action_compute(cr, uid, |
316 | 101 | [produce_id], properties=[x.id for x in procurement.property_ids]) | 101 | [produce_id], properties=[x.id for x in procurement.property_ids]) |
318 | 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) |
319 | 103 | if res_id: | 103 | if res_id: |
320 | 104 | move_obj.write(cr, uid, [res_id], | 104 | move_obj.write(cr, uid, [res_id], |
321 | 105 | {'location_id': procurement.location_id.id}) | 105 | {'location_id': procurement.location_id.id}) |
322 | 106 | 106 | ||
323 | === modified file 'mrp_operations/mrp_operations.py' | |||
324 | --- mrp_operations/mrp_operations.py 2011-12-08 09:49:28 +0000 | |||
325 | +++ mrp_operations/mrp_operations.py 2011-12-13 18:03:48 +0000 | |||
326 | @@ -156,14 +156,14 @@ | |||
327 | 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) |
328 | 157 | return result | 157 | return result |
329 | 158 | 158 | ||
331 | 159 | def action_draft(self, cr, uid, ids): | 159 | def action_draft(self, cr, uid, ids, context=None): |
332 | 160 | """ Sets state to draft. | 160 | """ Sets state to draft. |
333 | 161 | @return: True | 161 | @return: True |
334 | 162 | """ | 162 | """ |
335 | 163 | self.write(cr, uid, ids, {'state':'draft'}) | 163 | self.write(cr, uid, ids, {'state':'draft'}) |
336 | 164 | return True | 164 | return True |
337 | 165 | 165 | ||
339 | 166 | def action_start_working(self, cr, uid, ids): | 166 | def action_start_working(self, cr, uid, ids, context=None): |
340 | 167 | """ Sets state to start working and writes starting date. | 167 | """ Sets state to start working and writes starting date. |
341 | 168 | @return: True | 168 | @return: True |
342 | 169 | """ | 169 | """ |
343 | @@ -171,7 +171,7 @@ | |||
344 | 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')}) |
345 | 172 | return True | 172 | return True |
346 | 173 | 173 | ||
348 | 174 | def action_done(self, cr, uid, ids): | 174 | def action_done(self, cr, uid, ids, context=None): |
349 | 175 | """ Sets state to done, writes finish date and calculates delay. | 175 | """ Sets state to done, writes finish date and calculates delay. |
350 | 176 | @return: True | 176 | @return: True |
351 | 177 | """ | 177 | """ |
352 | @@ -188,21 +188,21 @@ | |||
353 | 188 | self.modify_production_order_state(cr,uid,ids,'done') | 188 | self.modify_production_order_state(cr,uid,ids,'done') |
354 | 189 | return True | 189 | return True |
355 | 190 | 190 | ||
357 | 191 | def action_cancel(self, cr, uid, ids): | 191 | def action_cancel(self, cr, uid, ids, context=None): |
358 | 192 | """ Sets state to cancel. | 192 | """ Sets state to cancel. |
359 | 193 | @return: True | 193 | @return: True |
360 | 194 | """ | 194 | """ |
361 | 195 | self.write(cr, uid, ids, {'state':'cancel'}) | 195 | self.write(cr, uid, ids, {'state':'cancel'}) |
362 | 196 | return True | 196 | return True |
363 | 197 | 197 | ||
365 | 198 | def action_pause(self, cr, uid, ids): | 198 | def action_pause(self, cr, uid, ids, context=None): |
366 | 199 | """ Sets state to pause. | 199 | """ Sets state to pause. |
367 | 200 | @return: True | 200 | @return: True |
368 | 201 | """ | 201 | """ |
369 | 202 | self.write(cr, uid, ids, {'state':'pause'}) | 202 | self.write(cr, uid, ids, {'state':'pause'}) |
370 | 203 | return True | 203 | return True |
371 | 204 | 204 | ||
373 | 205 | def action_resume(self, cr, uid, ids): | 205 | def action_resume(self, cr, uid, ids, context=None): |
374 | 206 | """ Sets state to startworking. | 206 | """ Sets state to startworking. |
375 | 207 | @return: True | 207 | @return: True |
376 | 208 | """ | 208 | """ |
377 | @@ -228,7 +228,7 @@ | |||
378 | 228 | result[prod.id] = max(line.date_planned_end, result[prod.id]) | 228 | result[prod.id] = max(line.date_planned_end, result[prod.id]) |
379 | 229 | return result | 229 | return result |
380 | 230 | 230 | ||
382 | 231 | def action_production_end(self, cr, uid, ids): | 231 | def action_production_end(self, cr, uid, ids, context=None): |
383 | 232 | """ Finishes work order if production order is done. | 232 | """ Finishes work order if production order is done. |
384 | 233 | @return: Super method | 233 | @return: Super method |
385 | 234 | """ | 234 | """ |
386 | @@ -236,11 +236,11 @@ | |||
387 | 236 | wf_service = netsvc.LocalService("workflow") | 236 | wf_service = netsvc.LocalService("workflow") |
388 | 237 | for workcenter_line in obj.workcenter_lines: | 237 | for workcenter_line in obj.workcenter_lines: |
389 | 238 | if workcenter_line.state == 'draft': | 238 | if workcenter_line.state == 'draft': |
393 | 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) |
394 | 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) |
395 | 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) |
396 | 242 | 242 | ||
398 | 243 | def action_in_production(self, cr, uid, ids): | 243 | def action_in_production(self, cr, uid, ids, context=None): |
399 | 244 | """ Changes state to In Production and writes starting date. | 244 | """ Changes state to In Production and writes starting date. |
400 | 245 | @return: True | 245 | @return: True |
401 | 246 | """ | 246 | """ |
402 | @@ -249,8 +249,8 @@ | |||
403 | 249 | wf_service = netsvc.LocalService("workflow") | 249 | wf_service = netsvc.LocalService("workflow") |
404 | 250 | for prod in self.browse(cr, uid, ids): | 250 | for prod in self.browse(cr, uid, ids): |
405 | 251 | if prod.workcenter_lines: | 251 | if prod.workcenter_lines: |
408 | 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) |
409 | 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) |
410 | 254 | 254 | ||
411 | 255 | def action_cancel(self, cr, uid, ids, context=None): | 255 | def action_cancel(self, cr, uid, ids, context=None): |
412 | 256 | """ Cancels work order if production order is canceled. | 256 | """ Cancels work order if production order is canceled. |
413 | @@ -259,7 +259,7 @@ | |||
414 | 259 | obj = self.browse(cr, uid, ids,context=context)[0] | 259 | obj = self.browse(cr, uid, ids,context=context)[0] |
415 | 260 | wf_service = netsvc.LocalService("workflow") | 260 | wf_service = netsvc.LocalService("workflow") |
416 | 261 | for workcenter_line in obj.workcenter_lines: | 261 | for workcenter_line in obj.workcenter_lines: |
418 | 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) |
419 | 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) |
420 | 264 | 264 | ||
421 | 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): |
422 | @@ -371,13 +371,13 @@ | |||
423 | 371 | pass | 371 | pass |
424 | 372 | return result | 372 | return result |
425 | 373 | 373 | ||
427 | 374 | def action_compute(self, cr, uid, ids, properties=[]): | 374 | def action_compute(self, cr, uid, ids, properties=[], context=None): |
428 | 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. |
429 | 376 | @param properties: List containing dictionaries of properties. | 376 | @param properties: List containing dictionaries of properties. |
430 | 377 | @return: No. of products. | 377 | @return: No. of products. |
431 | 378 | """ | 378 | """ |
434 | 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) |
435 | 380 | self._compute_planned_workcenter(cr, uid, ids, context={}) | 380 | self._compute_planned_workcenter(cr, uid, ids, context=context) |
436 | 381 | return result | 381 | return result |
437 | 382 | 382 | ||
438 | 383 | mrp_production() | 383 | mrp_production() |
439 | 384 | 384 | ||
440 | === modified file 'procurement/procurement.py' | |||
441 | --- procurement/procurement.py 2011-12-07 14:58:54 +0000 | |||
442 | +++ procurement/procurement.py 2011-12-13 18:03:48 +0000 | |||
443 | @@ -410,7 +410,7 @@ | |||
444 | 410 | """ | 410 | """ |
445 | 411 | return 0 | 411 | return 0 |
446 | 412 | 412 | ||
448 | 413 | def action_cancel(self, cr, uid, ids): | 413 | def action_cancel(self, cr, uid, ids, context=None): |
449 | 414 | """ Cancels procurement and writes move state to Assigned. | 414 | """ Cancels procurement and writes move state to Assigned. |
450 | 415 | @return: True | 415 | @return: True |
451 | 416 | """ | 416 | """ |
452 | @@ -431,13 +431,13 @@ | |||
453 | 431 | self.write(cr, uid, ids, {'state': 'cancel'}) | 431 | self.write(cr, uid, ids, {'state': 'cancel'}) |
454 | 432 | wf_service = netsvc.LocalService("workflow") | 432 | wf_service = netsvc.LocalService("workflow") |
455 | 433 | for id in ids: | 433 | for id in ids: |
457 | 434 | wf_service.trg_trigger(uid, 'procurement.order', id, cr) | 434 | wf_service.trg_trigger(uid, 'procurement.order', id, cr, context=context) |
458 | 435 | return True | 435 | return True |
459 | 436 | 436 | ||
461 | 437 | def action_check_finished(self, cr, uid, ids): | 437 | def action_check_finished(self, cr, uid, ids, context=None): |
462 | 438 | return self.check_move_done(cr, uid, ids) | 438 | return self.check_move_done(cr, uid, ids) |
463 | 439 | 439 | ||
465 | 440 | def action_check(self, cr, uid, ids): | 440 | def action_check(self, cr, uid, ids, context=None): |
466 | 441 | """ Checks procurement move state whether assigned or done. | 441 | """ Checks procurement move state whether assigned or done. |
467 | 442 | @return: True | 442 | @return: True |
468 | 443 | """ | 443 | """ |
469 | @@ -448,14 +448,14 @@ | |||
470 | 448 | ok = True | 448 | ok = True |
471 | 449 | return ok | 449 | return ok |
472 | 450 | 450 | ||
474 | 451 | def action_ready(self, cr, uid, ids): | 451 | def action_ready(self, cr, uid, ids, context=None): |
475 | 452 | """ Changes procurement state to Ready. | 452 | """ Changes procurement state to Ready. |
476 | 453 | @return: True | 453 | @return: True |
477 | 454 | """ | 454 | """ |
478 | 455 | res = self.write(cr, uid, ids, {'state': 'ready'}) | 455 | res = self.write(cr, uid, ids, {'state': 'ready'}) |
479 | 456 | return res | 456 | return res |
480 | 457 | 457 | ||
482 | 458 | def action_done(self, cr, uid, ids): | 458 | def action_done(self, cr, uid, ids, context=None): |
483 | 459 | """ Changes procurement state to Done and writes Closed date. | 459 | """ Changes procurement state to Done and writes Closed date. |
484 | 460 | @return: True | 460 | @return: True |
485 | 461 | """ | 461 | """ |
486 | @@ -463,11 +463,11 @@ | |||
487 | 463 | for procurement in self.browse(cr, uid, ids): | 463 | for procurement in self.browse(cr, uid, ids): |
488 | 464 | if procurement.move_id: | 464 | if procurement.move_id: |
489 | 465 | if procurement.close_move and (procurement.move_id.state <> 'done'): | 465 | if procurement.close_move and (procurement.move_id.state <> 'done'): |
491 | 466 | move_obj.action_done(cr, uid, [procurement.move_id.id]) | 466 | move_obj.action_done(cr, uid, [procurement.move_id.id], context=context) |
492 | 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')}) |
493 | 468 | wf_service = netsvc.LocalService("workflow") | 468 | wf_service = netsvc.LocalService("workflow") |
494 | 469 | for id in ids: | 469 | for id in ids: |
496 | 470 | wf_service.trg_trigger(uid, 'procurement.order', id, cr) | 470 | wf_service.trg_trigger(uid, 'procurement.order', id, cr, context=context) |
497 | 471 | return res | 471 | return res |
498 | 472 | 472 | ||
499 | 473 | procurement_order() | 473 | procurement_order() |
500 | @@ -475,7 +475,7 @@ | |||
501 | 475 | class StockPicking(osv.osv): | 475 | class StockPicking(osv.osv): |
502 | 476 | _inherit = 'stock.picking' | 476 | _inherit = 'stock.picking' |
503 | 477 | 477 | ||
505 | 478 | def test_finished(self, cursor, user, ids): | 478 | def test_finished(self, cursor, user, ids, context=None): |
506 | 479 | wf_service = netsvc.LocalService("workflow") | 479 | wf_service = netsvc.LocalService("workflow") |
507 | 480 | res = super(StockPicking, self).test_finished(cursor, user, ids) | 480 | res = super(StockPicking, self).test_finished(cursor, user, ids) |
508 | 481 | for picking in self.browse(cursor, user, ids): | 481 | for picking in self.browse(cursor, user, ids): |
509 | @@ -483,7 +483,7 @@ | |||
510 | 483 | if move.state == 'done' and move.procurements: | 483 | if move.state == 'done' and move.procurements: |
511 | 484 | for procurement in move.procurements: | 484 | for procurement in move.procurements: |
512 | 485 | wf_service.trg_validate(user, 'procurement.order', | 485 | wf_service.trg_validate(user, 'procurement.order', |
514 | 486 | procurement.id, 'button_check', cursor) | 486 | procurement.id, 'button_check', cursor, context=context) |
515 | 487 | return res | 487 | return res |
516 | 488 | 488 | ||
517 | 489 | StockPicking() | 489 | StockPicking() |
518 | 490 | 490 | ||
519 | === modified file 'purchase/purchase.py' | |||
520 | --- purchase/purchase.py 2011-12-01 21:32:12 +0000 | |||
521 | +++ purchase/purchase.py 2011-12-13 18:03:48 +0000 | |||
522 | @@ -339,15 +339,15 @@ | |||
523 | 339 | 'account_analytic_id': order_line.account_analytic_id.id or False, | 339 | 'account_analytic_id': order_line.account_analytic_id.id or False, |
524 | 340 | } | 340 | } |
525 | 341 | 341 | ||
527 | 342 | def action_cancel_draft(self, cr, uid, ids, *args): | 342 | def action_cancel_draft(self, cr, uid, ids, context=None): |
528 | 343 | if not len(ids): | 343 | if not len(ids): |
529 | 344 | return False | 344 | return False |
530 | 345 | self.write(cr, uid, ids, {'state':'draft','shipped':0}) | 345 | self.write(cr, uid, ids, {'state':'draft','shipped':0}) |
531 | 346 | wf_service = netsvc.LocalService("workflow") | 346 | wf_service = netsvc.LocalService("workflow") |
532 | 347 | for p_id in ids: | 347 | for p_id in ids: |
533 | 348 | # Deleting the existing instance of workflow for PO | 348 | # Deleting the existing instance of workflow for PO |
536 | 349 | wf_service.trg_delete(uid, 'purchase.order', p_id, cr) | 349 | wf_service.trg_delete(uid, 'purchase.order', p_id, cr, context=context) |
537 | 350 | wf_service.trg_create(uid, 'purchase.order', p_id, cr) | 350 | wf_service.trg_create(uid, 'purchase.order', p_id, cr, context=context) |
538 | 351 | for (id,name) in self.name_get(cr, uid, ids): | 351 | for (id,name) in self.name_get(cr, uid, ids): |
539 | 352 | message = _("Purchase order '%s' has been set in draft state.") % name | 352 | message = _("Purchase order '%s' has been set in draft state.") % name |
540 | 353 | self.log(cr, uid, id, message) | 353 | self.log(cr, uid, id, message) |
541 | @@ -421,7 +421,7 @@ | |||
542 | 421 | res = inv_id | 421 | res = inv_id |
543 | 422 | return res | 422 | return res |
544 | 423 | 423 | ||
546 | 424 | def has_stockable_product(self,cr, uid, ids, *args): | 424 | def has_stockable_product(self,cr, uid, ids, context=None): |
547 | 425 | for order in self.browse(cr, uid, ids): | 425 | for order in self.browse(cr, uid, ids): |
548 | 426 | for order_line in order.order_line: | 426 | for order_line in order.order_line: |
549 | 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'): |
550 | @@ -437,14 +437,14 @@ | |||
551 | 437 | _('Unable to cancel this purchase order!'), | 437 | _('Unable to cancel this purchase order!'), |
552 | 438 | _('You must first cancel all receptions related to this purchase order.')) | 438 | _('You must first cancel all receptions related to this purchase order.')) |
553 | 439 | for pick in purchase.picking_ids: | 439 | for pick in purchase.picking_ids: |
555 | 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) |
556 | 441 | for inv in purchase.invoice_ids: | 441 | for inv in purchase.invoice_ids: |
557 | 442 | if inv and inv.state not in ('cancel','draft'): | 442 | if inv and inv.state not in ('cancel','draft'): |
558 | 443 | raise osv.except_osv( | 443 | raise osv.except_osv( |
559 | 444 | _('Unable to cancel this purchase order!'), | 444 | _('Unable to cancel this purchase order!'), |
560 | 445 | _('You must first cancel all invoices related to this purchase order.')) | 445 | _('You must first cancel all invoices related to this purchase order.')) |
561 | 446 | if inv: | 446 | if inv: |
563 | 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) |
564 | 448 | self.write(cr,uid,ids,{'state':'cancel'}) | 448 | self.write(cr,uid,ids,{'state':'cancel'}) |
565 | 449 | 449 | ||
566 | 450 | for (id, name) in self.name_get(cr, uid, ids): | 450 | for (id, name) in self.name_get(cr, uid, ids): |
567 | @@ -453,7 +453,7 @@ | |||
568 | 453 | self.log(cr, uid, id, message) | 453 | self.log(cr, uid, id, message) |
569 | 454 | return True | 454 | return True |
570 | 455 | 455 | ||
572 | 456 | def _prepare_order_picking(self, cr, uid, order, *args): | 456 | def _prepare_order_picking(self, cr, uid, order, context=None): |
573 | 457 | return { | 457 | return { |
574 | 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'), |
575 | 459 | 'origin': order.name + ((order.origin and (':' + order.origin)) or ''), | 459 | 'origin': order.name + ((order.origin and (':' + order.origin)) or ''), |
576 | @@ -466,7 +466,7 @@ | |||
577 | 466 | 'move_lines' : [], | 466 | 'move_lines' : [], |
578 | 467 | } | 467 | } |
579 | 468 | 468 | ||
581 | 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): |
582 | 470 | return { | 470 | return { |
583 | 471 | 'name': order.name + ': ' + (order_line.name or ''), | 471 | 'name': order.name + ': ' + (order_line.name or ''), |
584 | 472 | 'product_id': order_line.product_id.id, | 472 | 'product_id': order_line.product_id.id, |
585 | @@ -487,7 +487,7 @@ | |||
586 | 487 | 'price_unit': order_line.price_unit | 487 | 'price_unit': order_line.price_unit |
587 | 488 | } | 488 | } |
588 | 489 | 489 | ||
590 | 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): |
591 | 491 | """Creates pickings and appropriate stock moves for given order lines, then | 491 | """Creates pickings and appropriate stock moves for given order lines, then |
592 | 492 | confirms the moves, makes them available, and confirms the picking. | 492 | confirms the moves, makes them available, and confirms the picking. |
593 | 493 | 493 | ||
594 | @@ -507,7 +507,7 @@ | |||
595 | 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) |
596 | 508 | """ | 508 | """ |
597 | 509 | if not picking_id: | 509 | if not picking_id: |
599 | 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)) |
600 | 511 | todo_moves = [] | 511 | todo_moves = [] |
601 | 512 | stock_move = self.pool.get('stock.move') | 512 | stock_move = self.pool.get('stock.move') |
602 | 513 | wf_service = netsvc.LocalService("workflow") | 513 | wf_service = netsvc.LocalService("workflow") |
603 | @@ -515,19 +515,19 @@ | |||
604 | 515 | if not order_line.product_id: | 515 | if not order_line.product_id: |
605 | 516 | continue | 516 | continue |
606 | 517 | if order_line.product_id.type in ('product', 'consu'): | 517 | if order_line.product_id.type in ('product', 'consu'): |
608 | 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)) |
609 | 519 | if order_line.move_dest_id: | 519 | if order_line.move_dest_id: |
610 | 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}) |
611 | 521 | todo_moves.append(move) | 521 | todo_moves.append(move) |
615 | 522 | stock_move.action_confirm(cr, uid, todo_moves) | 522 | stock_move.action_confirm(cr, uid, todo_moves, context=context) |
616 | 523 | stock_move.force_assign(cr, uid, todo_moves) | 523 | stock_move.force_assign(cr, uid, todo_moves, context=context) |
617 | 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) |
618 | 525 | return [picking_id] | 525 | return [picking_id] |
619 | 526 | 526 | ||
621 | 527 | def action_picking_create(self,cr, uid, ids, *args): | 527 | def action_picking_create(self,cr, uid, ids, context=None): |
622 | 528 | picking_ids = [] | 528 | picking_ids = [] |
623 | 529 | for order in self.browse(cr, uid, ids): | 529 | for order in self.browse(cr, uid, ids): |
625 | 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)) |
626 | 531 | 531 | ||
627 | 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. |
628 | 533 | # In case of multiple (split) pickings, we should return the ID of the critical one, i.e. the | 533 | # In case of multiple (split) pickings, we should return the ID of the critical one, i.e. the |
629 | @@ -730,7 +730,7 @@ | |||
630 | 730 | # - split into small internal methods for clearity | 730 | # - split into small internal methods for clearity |
631 | 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, |
632 | 732 | partner_id, date_order=False, fiscal_position=False, date_planned=False, | 732 | partner_id, date_order=False, fiscal_position=False, date_planned=False, |
634 | 733 | name=False, price_unit=False, notes=False, context={}): | 733 | name=False, price_unit=False, notes=False, context=None): |
635 | 734 | if not pricelist: | 734 | if not pricelist: |
636 | 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.')) |
637 | 736 | if not partner_id: | 736 | if not partner_id: |
638 | @@ -744,8 +744,9 @@ | |||
639 | 744 | lang=False | 744 | lang=False |
640 | 745 | if partner_id: | 745 | if partner_id: |
641 | 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'] |
644 | 747 | context={'lang':lang} | 747 | if context is None: |
645 | 748 | context['partner_id'] = partner_id | 748 | context = {} |
646 | 749 | context = dict(context, lang=lang, partner_id=partner_id) | ||
647 | 749 | 750 | ||
648 | 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) |
649 | 751 | prod_uom_po = prod.uom_po_id.id | 752 | prod_uom_po = prod.uom_po_id.id |
650 | @@ -805,7 +806,7 @@ | |||
651 | 805 | # - merge into 'product_id_change' method | 806 | # - merge into 'product_id_change' method |
652 | 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, |
653 | 807 | partner_id, date_order=False, fiscal_position=False, date_planned=False, | 808 | partner_id, date_order=False, fiscal_position=False, date_planned=False, |
655 | 808 | name=False, price_unit=False, notes=False, context={}): | 809 | name=False, price_unit=False, notes=False, context=None): |
656 | 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, |
657 | 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, |
658 | 811 | name=name, price_unit=price_unit, notes=notes, context=context) | 812 | name=name, price_unit=price_unit, notes=notes, context=context) |
659 | 812 | 813 | ||
660 | === modified file 'sale/sale.py' | |||
661 | --- sale/sale.py 2011-12-11 11:09:56 +0000 | |||
662 | +++ sale/sale.py 2011-12-13 18:03:48 +0000 | |||
663 | @@ -306,7 +306,7 @@ | |||
664 | 306 | v['pricelist_id'] = shop.pricelist_id.id | 306 | v['pricelist_id'] = shop.pricelist_id.id |
665 | 307 | return {'value': v} | 307 | return {'value': v} |
666 | 308 | 308 | ||
668 | 309 | def action_cancel_draft(self, cr, uid, ids, *args): | 309 | def action_cancel_draft(self, cr, uid, ids, context=None): |
669 | 310 | if not len(ids): | 310 | if not len(ids): |
670 | 311 | return False | 311 | return False |
671 | 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')) |
672 | @@ -316,14 +316,14 @@ | |||
673 | 316 | wf_service = netsvc.LocalService("workflow") | 316 | wf_service = netsvc.LocalService("workflow") |
674 | 317 | for inv_id in ids: | 317 | for inv_id in ids: |
675 | 318 | # Deleting the existing instance of workflow for SO | 318 | # Deleting the existing instance of workflow for SO |
678 | 319 | wf_service.trg_delete(uid, 'sale.order', inv_id, cr) | 319 | wf_service.trg_delete(uid, 'sale.order', inv_id, cr, context=context) |
679 | 320 | wf_service.trg_create(uid, 'sale.order', inv_id, cr) | 320 | wf_service.trg_create(uid, 'sale.order', inv_id, cr, context=context) |
680 | 321 | for (id,name) in self.name_get(cr, uid, ids): | 321 | for (id,name) in self.name_get(cr, uid, ids): |
681 | 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,) |
682 | 323 | self.log(cr, uid, id, message) | 323 | self.log(cr, uid, id, message) |
683 | 324 | return True | 324 | return True |
684 | 325 | 325 | ||
686 | 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): |
687 | 327 | print order_lines | 327 | print order_lines |
688 | 328 | if (not pricelist_id) or (not order_lines): | 328 | if (not pricelist_id) or (not order_lines): |
689 | 329 | return {} | 329 | return {} |
690 | @@ -333,6 +333,7 @@ | |||
691 | 333 | } | 333 | } |
692 | 334 | return {'warning': warning} | 334 | return {'warning': warning} |
693 | 335 | 335 | ||
694 | 336 | <<<<<<< TREE | ||
695 | 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={}): |
696 | 337 | if not order_id: | 338 | if not order_id: |
697 | 338 | return {} | 339 | return {} |
698 | @@ -344,6 +345,9 @@ | |||
699 | 344 | return {'value': val} | 345 | return {'value': val} |
700 | 345 | 346 | ||
701 | 346 | def onchange_partner_id(self, cr, uid, ids, part): | 347 | def onchange_partner_id(self, cr, uid, ids, part): |
702 | 348 | ======= | ||
703 | 349 | def onchange_partner_id(self, cr, uid, ids, part, context=None): | ||
704 | 350 | >>>>>>> MERGE-SOURCE | ||
705 | 347 | if not part: | 351 | if not part: |
706 | 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}} |
707 | 349 | 353 | ||
708 | @@ -608,7 +612,7 @@ | |||
709 | 608 | proc_ids = proc_obj.search(cr, uid, [('move_id', '=', mov.id)]) | 612 | proc_ids = proc_obj.search(cr, uid, [('move_id', '=', mov.id)]) |
710 | 609 | if proc_ids: | 613 | if proc_ids: |
711 | 610 | for proc in proc_ids: | 614 | for proc in proc_ids: |
713 | 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) |
714 | 612 | for r in self.read(cr, uid, ids, ['picking_ids']): | 616 | for r in self.read(cr, uid, ids, ['picking_ids']): |
715 | 613 | for pick in r['picking_ids']: | 617 | for pick in r['picking_ids']: |
716 | 614 | wf_service.trg_validate(uid, 'stock.picking', pick, 'button_cancel', cr) | 618 | wf_service.trg_validate(uid, 'stock.picking', pick, 'button_cancel', cr) |
717 | @@ -619,7 +623,7 @@ | |||
718 | 619 | _('You must first cancel all invoices attached to this sales order.')) | 623 | _('You must first cancel all invoices attached to this sales order.')) |
719 | 620 | for r in self.read(cr, uid, ids, ['invoice_ids']): | 624 | for r in self.read(cr, uid, ids, ['invoice_ids']): |
720 | 621 | for inv in r['invoice_ids']: | 625 | for inv in r['invoice_ids']: |
722 | 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) |
723 | 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], |
724 | 624 | {'state': 'cancel'}) | 628 | {'state': 'cancel'}) |
725 | 625 | message = _("The sales order '%s' has been cancelled.") % (sale.name,) | 629 | message = _("The sales order '%s' has been cancelled.") % (sale.name,) |
726 | @@ -627,7 +631,7 @@ | |||
727 | 627 | self.write(cr, uid, ids, {'state': 'cancel'}) | 631 | self.write(cr, uid, ids, {'state': 'cancel'}) |
728 | 628 | return True | 632 | return True |
729 | 629 | 633 | ||
731 | 630 | def action_wait(self, cr, uid, ids, *args): | 634 | def action_wait(self, cr, uid, ids, context=None): |
732 | 631 | for o in self.browse(cr, uid, ids): | 635 | for o in self.browse(cr, uid, ids): |
733 | 632 | if not o.order_line: | 636 | if not o.order_line: |
734 | 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.')) |
735 | @@ -635,12 +639,12 @@ | |||
736 | 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)}) |
737 | 636 | else: | 640 | else: |
738 | 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)}) |
740 | 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) |
741 | 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,) |
742 | 640 | self.log(cr, uid, o.id, message) | 644 | self.log(cr, uid, o.id, message) |
743 | 641 | return True | 645 | return True |
744 | 642 | 646 | ||
746 | 643 | def procurement_lines_get(self, cr, uid, ids, *args): | 647 | def procurement_lines_get(self, cr, uid, ids, context=None): |
747 | 644 | res = [] | 648 | res = [] |
748 | 645 | for order in self.browse(cr, uid, ids, context={}): | 649 | for order in self.browse(cr, uid, ids, context={}): |
749 | 646 | for line in order.order_line: | 650 | for line in order.order_line: |
750 | @@ -652,14 +656,14 @@ | |||
751 | 652 | # returns True if all lines are done, False otherwise | 656 | # returns True if all lines are done, False otherwise |
752 | 653 | # if mode == 'canceled': | 657 | # if mode == 'canceled': |
753 | 654 | # returns True if there is at least one canceled line, False otherwise | 658 | # returns True if there is at least one canceled line, False otherwise |
755 | 655 | def test_state(self, cr, uid, ids, mode, *args): | 659 | def test_state(self, cr, uid, ids, mode, context=None): |
756 | 656 | assert mode in ('finished', 'canceled'), _("invalid mode for test_state") | 660 | assert mode in ('finished', 'canceled'), _("invalid mode for test_state") |
757 | 657 | finished = True | 661 | finished = True |
758 | 658 | canceled = False | 662 | canceled = False |
759 | 659 | notcanceled = False | 663 | notcanceled = False |
760 | 660 | write_done_ids = [] | 664 | write_done_ids = [] |
761 | 661 | write_cancel_ids = [] | 665 | write_cancel_ids = [] |
763 | 662 | for order in self.browse(cr, uid, ids, context={}): | 666 | for order in self.browse(cr, uid, ids, context=context): |
764 | 663 | for line in order.order_line: | 667 | for line in order.order_line: |
765 | 664 | if (not line.procurement_id) or (line.procurement_id.state=='done'): | 668 | if (not line.procurement_id) or (line.procurement_id.state=='done'): |
766 | 665 | if line.state != 'done': | 669 | if line.state != 'done': |
767 | @@ -686,7 +690,7 @@ | |||
768 | 686 | return False | 690 | return False |
769 | 687 | return canceled | 691 | return canceled |
770 | 688 | 692 | ||
772 | 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): |
773 | 690 | return { | 694 | return { |
774 | 691 | 'name': line.name, | 695 | 'name': line.name, |
775 | 692 | 'origin': order.name, | 696 | 'origin': order.name, |
776 | @@ -707,7 +711,7 @@ | |||
777 | 707 | 'company_id': order.company_id.id, | 711 | 'company_id': order.company_id.id, |
778 | 708 | } | 712 | } |
779 | 709 | 713 | ||
781 | 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): |
782 | 711 | location_id = order.shop_id.warehouse_id.lot_stock_id.id | 715 | location_id = order.shop_id.warehouse_id.lot_stock_id.id |
783 | 712 | output_id = order.shop_id.warehouse_id.lot_output_id.id | 716 | output_id = order.shop_id.warehouse_id.lot_output_id.id |
784 | 713 | return { | 717 | return { |
785 | @@ -734,7 +738,7 @@ | |||
786 | 734 | 'price_unit': line.product_id.standard_price or 0.0 | 738 | 'price_unit': line.product_id.standard_price or 0.0 |
787 | 735 | } | 739 | } |
788 | 736 | 740 | ||
790 | 737 | def _prepare_order_picking(self, cr, uid, order, *args): | 741 | def _prepare_order_picking(self, cr, uid, order, context=None): |
791 | 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') |
792 | 739 | return { | 743 | return { |
793 | 740 | 'name': pick_name, | 744 | 'name': pick_name, |
794 | @@ -750,7 +754,7 @@ | |||
795 | 750 | 'company_id': order.company_id.id, | 754 | 'company_id': order.company_id.id, |
796 | 751 | } | 755 | } |
797 | 752 | 756 | ||
799 | 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): |
800 | 754 | """Create the required procurements to supply sale order lines, also connecting | 758 | """Create the required procurements to supply sale order lines, also connecting |
801 | 755 | the procurements to appropriate stock moves in order to bring the goods to the | 759 | the procurements to appropriate stock moves in order to bring the goods to the |
802 | 756 | sale order's requested location. | 760 | sale order's requested location. |
803 | @@ -784,13 +788,13 @@ | |||
804 | 784 | if line.product_id: | 788 | if line.product_id: |
805 | 785 | if line.product_id.product_tmpl_id.type in ('product', 'consu'): | 789 | if line.product_id.product_tmpl_id.type in ('product', 'consu'): |
806 | 786 | if not picking_id: | 790 | if not picking_id: |
809 | 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)) |
810 | 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)) |
811 | 789 | else: | 793 | else: |
812 | 790 | # a service has no stock move | 794 | # a service has no stock move |
813 | 791 | move_id = False | 795 | move_id = False |
814 | 792 | 796 | ||
816 | 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)) |
817 | 794 | proc_ids.append(proc_id) | 798 | proc_ids.append(proc_id) |
818 | 795 | line.write({'procurement_id': proc_id}) | 799 | line.write({'procurement_id': proc_id}) |
819 | 796 | 800 | ||
820 | @@ -809,10 +813,10 @@ | |||
821 | 809 | 813 | ||
822 | 810 | wf_service = netsvc.LocalService("workflow") | 814 | wf_service = netsvc.LocalService("workflow") |
823 | 811 | if picking_id: | 815 | if picking_id: |
825 | 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) |
826 | 813 | 817 | ||
827 | 814 | for proc_id in proc_ids: | 818 | for proc_id in proc_ids: |
829 | 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) |
830 | 816 | 820 | ||
831 | 817 | val = {} | 821 | val = {} |
832 | 818 | if order.state == 'shipping_except': | 822 | if order.state == 'shipping_except': |
833 | @@ -827,9 +831,9 @@ | |||
834 | 827 | order.write(val) | 831 | order.write(val) |
835 | 828 | return True | 832 | return True |
836 | 829 | 833 | ||
840 | 830 | def action_ship_create(self, cr, uid, ids, *args): | 834 | def action_ship_create(self, cr, uid, ids, context=None): |
841 | 831 | for order in self.browse(cr, uid, ids, context={}): | 835 | for order in self.browse(cr, uid, ids, context=context): |
842 | 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) |
843 | 833 | return True | 837 | return True |
844 | 834 | 838 | ||
845 | 835 | def action_ship_end(self, cr, uid, ids, context=None): | 839 | def action_ship_end(self, cr, uid, ids, context=None): |
846 | @@ -1041,7 +1045,7 @@ | |||
847 | 1041 | # Trigger workflow events | 1045 | # Trigger workflow events |
848 | 1042 | wf_service = netsvc.LocalService("workflow") | 1046 | wf_service = netsvc.LocalService("workflow") |
849 | 1043 | for sid in sales.keys(): | 1047 | for sid in sales.keys(): |
851 | 1044 | wf_service.trg_write(uid, 'sale.order', sid, cr) | 1048 | wf_service.trg_write(uid, 'sale.order', sid, cr, context=context) |
852 | 1045 | return create_ids | 1049 | return create_ids |
853 | 1046 | 1050 | ||
854 | 1047 | def button_cancel(self, cr, uid, ids, context=None): | 1051 | def button_cancel(self, cr, uid, ids, context=None): |
855 | @@ -1065,7 +1069,7 @@ | |||
856 | 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) |
857 | 1066 | return res | 1070 | return res |
858 | 1067 | 1071 | ||
860 | 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): |
861 | 1069 | product_obj = self.pool.get('product.product') | 1073 | product_obj = self.pool.get('product.product') |
862 | 1070 | if not product_id: | 1074 | if not product_id: |
863 | 1071 | return {'value': {'product_uom': product_uos, | 1075 | return {'value': {'product_uom': product_uos, |
864 | 1072 | 1076 | ||
865 | === modified file 'stock/stock.py' | |||
866 | --- stock/stock.py 2011-12-01 21:32:12 +0000 | |||
867 | +++ stock/stock.py 2011-12-13 18:03:48 +0000 | |||
868 | @@ -739,7 +739,7 @@ | |||
869 | 739 | # TODO: Check locations to see if in the same location ? | 739 | # TODO: Check locations to see if in the same location ? |
870 | 740 | return True | 740 | return True |
871 | 741 | 741 | ||
873 | 742 | def action_assign(self, cr, uid, ids, *args): | 742 | def action_assign(self, cr, uid, ids, context=None): |
874 | 743 | """ Changes state of picking to available if all moves are confirmed. | 743 | """ Changes state of picking to available if all moves are confirmed. |
875 | 744 | @return: True | 744 | @return: True |
876 | 745 | """ | 745 | """ |
877 | @@ -750,7 +750,7 @@ | |||
878 | 750 | self.pool.get('stock.move').action_assign(cr, uid, move_ids) | 750 | self.pool.get('stock.move').action_assign(cr, uid, move_ids) |
879 | 751 | return True | 751 | return True |
880 | 752 | 752 | ||
882 | 753 | def force_assign(self, cr, uid, ids, *args): | 753 | def force_assign(self, cr, uid, ids, context=None): |
883 | 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. |
884 | 755 | @return: True | 755 | @return: True |
885 | 756 | """ | 756 | """ |
886 | @@ -758,10 +758,10 @@ | |||
887 | 758 | for pick in self.browse(cr, uid, ids): | 758 | for pick in self.browse(cr, uid, ids): |
888 | 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']] |
889 | 760 | self.pool.get('stock.move').force_assign(cr, uid, move_ids) | 760 | self.pool.get('stock.move').force_assign(cr, uid, move_ids) |
891 | 761 | wf_service.trg_write(uid, 'stock.picking', pick.id, cr) | 761 | wf_service.trg_write(uid, 'stock.picking', pick.id, cr, context=context) |
892 | 762 | return True | 762 | return True |
893 | 763 | 763 | ||
895 | 764 | def draft_force_assign(self, cr, uid, ids, *args): | 764 | def draft_force_assign(self, cr, uid, ids, context=None): |
896 | 765 | """ Confirms picking directly from draft state. | 765 | """ Confirms picking directly from draft state. |
897 | 766 | @return: True | 766 | @return: True |
898 | 767 | """ | 767 | """ |
899 | @@ -770,7 +770,7 @@ | |||
900 | 770 | if not pick.move_lines: | 770 | if not pick.move_lines: |
901 | 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')) |
902 | 772 | wf_service.trg_validate(uid, 'stock.picking', pick.id, | 772 | wf_service.trg_validate(uid, 'stock.picking', pick.id, |
904 | 773 | 'button_confirm', cr) | 773 | 'button_confirm', cr, context=context) |
905 | 774 | return True | 774 | return True |
906 | 775 | 775 | ||
907 | 776 | def draft_validate(self, cr, uid, ids, context=None): | 776 | def draft_validate(self, cr, uid, ids, context=None): |
908 | @@ -782,10 +782,10 @@ | |||
909 | 782 | for pick in self.browse(cr, uid, ids, context=context): | 782 | for pick in self.browse(cr, uid, ids, context=context): |
910 | 783 | move_ids = [x.id for x in pick.move_lines] | 783 | move_ids = [x.id for x in pick.move_lines] |
911 | 784 | self.pool.get('stock.move').force_assign(cr, uid, move_ids) | 784 | self.pool.get('stock.move').force_assign(cr, uid, move_ids) |
913 | 785 | wf_service.trg_write(uid, 'stock.picking', pick.id, cr) | 785 | wf_service.trg_write(uid, 'stock.picking', pick.id, cr, context=context) |
914 | 786 | return self.action_process( | 786 | return self.action_process( |
915 | 787 | cr, uid, ids, context=context) | 787 | cr, uid, ids, context=context) |
917 | 788 | def cancel_assign(self, cr, uid, ids, *args): | 788 | def cancel_assign(self, cr, uid, ids, context=None): |
918 | 789 | """ Cancels picking and moves. | 789 | """ Cancels picking and moves. |
919 | 790 | @return: True | 790 | @return: True |
920 | 791 | """ | 791 | """ |
921 | @@ -793,7 +793,7 @@ | |||
922 | 793 | for pick in self.browse(cr, uid, ids): | 793 | for pick in self.browse(cr, uid, ids): |
923 | 794 | move_ids = [x.id for x in pick.move_lines] | 794 | move_ids = [x.id for x in pick.move_lines] |
924 | 795 | self.pool.get('stock.move').cancel_assign(cr, uid, move_ids) | 795 | self.pool.get('stock.move').cancel_assign(cr, uid, move_ids) |
926 | 796 | wf_service.trg_write(uid, 'stock.picking', pick.id, cr) | 796 | wf_service.trg_write(uid, 'stock.picking', pick.id, cr, context=context) |
927 | 797 | return True | 797 | return True |
928 | 798 | 798 | ||
929 | 799 | def action_assign_wkf(self, cr, uid, ids, context=None): | 799 | def action_assign_wkf(self, cr, uid, ids, context=None): |
930 | @@ -804,7 +804,7 @@ | |||
931 | 804 | self.log_picking(cr, uid, ids, context=context) | 804 | self.log_picking(cr, uid, ids, context=context) |
932 | 805 | return True | 805 | return True |
933 | 806 | 806 | ||
935 | 807 | def test_finished(self, cr, uid, ids): | 807 | def test_finished(self, cr, uid, ids, context=None): |
936 | 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. |
937 | 809 | @return: True or False | 809 | @return: True or False |
938 | 810 | """ | 810 | """ |
939 | @@ -818,7 +818,7 @@ | |||
940 | 818 | move.write({'state': 'done'}) | 818 | move.write({'state': 'done'}) |
941 | 819 | return True | 819 | return True |
942 | 820 | 820 | ||
944 | 821 | def test_assigned(self, cr, uid, ids): | 821 | def test_assigned(self, cr, uid, ids, context=None): |
945 | 822 | """ Tests whether the move is in assigned state or not. | 822 | """ Tests whether the move is in assigned state or not. |
946 | 823 | @return: True or False | 823 | @return: True or False |
947 | 824 | """ | 824 | """ |
948 | @@ -1284,16 +1284,16 @@ | |||
949 | 1284 | 1284 | ||
950 | 1285 | # At first we confirm the new picking (if necessary) | 1285 | # At first we confirm the new picking (if necessary) |
951 | 1286 | if new_picking: | 1286 | if new_picking: |
953 | 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) |
954 | 1288 | # Then we finish the good picking | 1288 | # Then we finish the good picking |
955 | 1289 | self.write(cr, uid, [pick.id], {'backorder_id': new_picking}) | 1289 | self.write(cr, uid, [pick.id], {'backorder_id': new_picking}) |
959 | 1290 | self.action_move(cr, uid, [new_picking]) | 1290 | self.action_move(cr, uid, [new_picking], context=context) |
960 | 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) |
961 | 1292 | wf_service.trg_write(uid, 'stock.picking', pick.id, cr) | 1292 | wf_service.trg_write(uid, 'stock.picking', pick.id, cr, context=context) |
962 | 1293 | delivered_pack_id = new_picking | 1293 | delivered_pack_id = new_picking |
963 | 1294 | else: | 1294 | else: |
964 | 1295 | self.action_move(cr, uid, [pick.id]) | 1295 | self.action_move(cr, uid, [pick.id]) |
966 | 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) |
967 | 1297 | delivered_pack_id = pick.id | 1297 | delivered_pack_id = pick.id |
968 | 1298 | 1298 | ||
969 | 1299 | delivered_pack = self.browse(cr, uid, delivered_pack_id, context=context) | 1299 | delivered_pack = self.browse(cr, uid, delivered_pack_id, context=context) |
970 | @@ -1909,7 +1909,7 @@ | |||
971 | 1909 | }) | 1909 | }) |
972 | 1910 | new_moves.append(self.browse(cr, uid, [new_id])[0]) | 1910 | new_moves.append(self.browse(cr, uid, [new_id])[0]) |
973 | 1911 | if pickid: | 1911 | if pickid: |
975 | 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) |
976 | 1913 | if new_moves: | 1913 | if new_moves: |
977 | 1914 | new_moves += self.create_chained_picking(cr, uid, new_moves, context) | 1914 | new_moves += self.create_chained_picking(cr, uid, new_moves, context) |
978 | 1915 | return new_moves | 1915 | return new_moves |
979 | @@ -1920,10 +1920,10 @@ | |||
980 | 1920 | """ | 1920 | """ |
981 | 1921 | moves = self.browse(cr, uid, ids, context=context) | 1921 | moves = self.browse(cr, uid, ids, context=context) |
982 | 1922 | self.write(cr, uid, ids, {'state': 'confirmed'}) | 1922 | self.write(cr, uid, ids, {'state': 'confirmed'}) |
984 | 1923 | self.create_chained_picking(cr, uid, moves, context) | 1923 | self.create_chained_picking(cr, uid, moves, context=context) |
985 | 1924 | return [] | 1924 | return [] |
986 | 1925 | 1925 | ||
988 | 1926 | def action_assign(self, cr, uid, ids, *args): | 1926 | def action_assign(self, cr, uid, ids, context=None): |
989 | 1927 | """ Changes state to confirmed or waiting. | 1927 | """ Changes state to confirmed or waiting. |
990 | 1928 | @return: List of values | 1928 | @return: List of values |
991 | 1929 | """ | 1929 | """ |
992 | @@ -1931,7 +1931,7 @@ | |||
993 | 1931 | for move in self.browse(cr, uid, ids): | 1931 | for move in self.browse(cr, uid, ids): |
994 | 1932 | if move.state in ('confirmed', 'waiting'): | 1932 | if move.state in ('confirmed', 'waiting'): |
995 | 1933 | todo.append(move.id) | 1933 | todo.append(move.id) |
997 | 1934 | res = self.check_assign(cr, uid, todo) | 1934 | res = self.check_assign(cr, uid, todo, context=context) |
998 | 1935 | return res | 1935 | return res |
999 | 1936 | 1936 | ||
1000 | 1937 | def force_assign(self, cr, uid, ids, context=None): | 1937 | def force_assign(self, cr, uid, ids, context=None): |
1001 | @@ -2203,10 +2203,10 @@ | |||
1002 | 2203 | 2203 | ||
1003 | 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) |
1004 | 2205 | for id in move_ids: | 2205 | for id in move_ids: |
1006 | 2206 | wf_service.trg_trigger(uid, 'stock.move', id, cr) | 2206 | wf_service.trg_trigger(uid, 'stock.move', id, cr, context=context) |
1007 | 2207 | 2207 | ||
1008 | 2208 | for pick_id in picking_ids: | 2208 | for pick_id in picking_ids: |
1010 | 2209 | wf_service.trg_write(uid, 'stock.picking', pick_id, cr) | 2209 | wf_service.trg_write(uid, 'stock.picking', pick_id, cr, context=context) |
1011 | 2210 | 2210 | ||
1012 | 2211 | return True | 2211 | return True |
1013 | 2212 | 2212 | ||
1014 | 2213 | 2213 | ||
1015 | === modified file 'stock_location/procurement_pull.py' | |||
1016 | --- stock_location/procurement_pull.py 2011-11-24 15:50:58 +0000 | |||
1017 | +++ stock_location/procurement_pull.py 2011-12-13 18:03:48 +0000 | |||
1018 | @@ -45,7 +45,7 @@ | |||
1019 | 45 | return (line.type_proc=='move') and (line.location_src_id) | 45 | return (line.type_proc=='move') and (line.location_src_id) |
1020 | 46 | return False | 46 | return False |
1021 | 47 | 47 | ||
1023 | 48 | def action_move_create(self, cr, uid, ids,context=None): | 48 | def action_move_create(self, cr, uid, ids, context=None): |
1024 | 49 | proc_obj = self.pool.get('procurement.order') | 49 | proc_obj = self.pool.get('procurement.order') |
1025 | 50 | move_obj = self.pool.get('stock.move') | 50 | move_obj = self.pool.get('stock.move') |
1026 | 51 | picking_obj=self.pool.get('stock.picking') | 51 | picking_obj=self.pool.get('stock.picking') |
1027 | @@ -110,15 +110,15 @@ | |||
1028 | 110 | 'move_id': move_id, | 110 | 'move_id': move_id, |
1029 | 111 | }) | 111 | }) |
1030 | 112 | wf_service = netsvc.LocalService("workflow") | 112 | wf_service = netsvc.LocalService("workflow") |
1033 | 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) |
1034 | 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) |
1035 | 115 | if proc.move_id: | 115 | if proc.move_id: |
1036 | 116 | move_obj.write(cr, uid, [proc.move_id.id], | 116 | move_obj.write(cr, uid, [proc.move_id.id], |
1037 | 117 | {'location_id':proc.location_id.id}) | 117 | {'location_id':proc.location_id.id}) |
1038 | 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}) |
1039 | 119 | 119 | ||
1040 | 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) |
1042 | 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) |
1043 | 122 | return False | 122 | return False |
1044 | 123 | 123 | ||
1045 | 124 | procurement_order() | 124 | procurement_order() |