Merge lp:~the-clone-master/ocb-addons/6.1-lp212930-purchase_anglo_saxon_invoice_from_PO_lines into lp:ocb-addons/6.1
- 6.1-lp212930-purchase_anglo_saxon_invoice_from_PO_lines
- Merge into 6.1
Status: | Merged |
---|---|
Merged at revision: | 6800 |
Proposed branch: | lp:~the-clone-master/ocb-addons/6.1-lp212930-purchase_anglo_saxon_invoice_from_PO_lines |
Merge into: | lp:ocb-addons/6.1 |
Diff against target: |
163 lines (+35/-56) 3 files modified
account_anglo_saxon/purchase.py (+7/-7) purchase/purchase.py (+15/-13) purchase/wizard/purchase_line_invoice.py (+13/-36) |
To merge this branch: | bzr merge lp:~the-clone-master/ocb-addons/6.1-lp212930-purchase_anglo_saxon_invoice_from_PO_lines |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Paulius Sladkevičius @ hbee (community) | Needs Fixing | ||
Holger Brunn (Therp) | code review | Approve | |
Virgil Dupras (community) | Approve | ||
Stefan Rijnhart (Opener) | code review | Approve | |
Review via email:
|
Commit message
Description of the change
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mario Arias (the-clone-master) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Stefan Rijnhart (Opener) (stefan-opener) wrote : | # |
Hi Mario,
Great work! I verified that the diff is equivalent to http://
I was going to ask you about the status in 7.0 (we don't want to introduce regressions by fixing things in older releases only) but I noticed that for 7.0 it is already fixed here: http://
By convention, I am setting the related issue to 'Affecting OpenERP 6.1' with status Won't Fix and the status in OCB-Addons to Fix Committed, as your proposal has not yet been merged in the main branch.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mario Arias (the-clone-master) wrote : | # |
Hi Stefan,
Sorry, I forgot to mention that it was already fixed for 7.0.
I am working on Kevin McMenamin's modules for landed cost, to port them
to 6.1 and later on to 7.0.
As part of their work, they have fixed a lot of issues with official
Anglo Saxon module, and I will be reporting them on launchpad to try to
get them fixed on official and OCB branches.
When done, I will ask him for permission to make them public, as they
made an excellent job. Maybe we can have them on community project...
Regards,
-Mario
On Sat 17 Aug 2013 03:40:07 AM CST, Stefan Rijnhart (Therp) wrote:
> Review: Approve code review
>
> Hi Mario,
>
> Great work! I verified that the diff is equivalent to http://
>
> I was going to ask you about the status in 7.0 (we don't want to introduce regressions by fixing things in older releases only) but I noticed that for 7.0 it is already fixed here: http://
>
> By convention, I am setting the related issue to 'Affecting OpenERP 6.1' with status Won't Fix and the status in OCB-Addons to Fix Committed, as your proposal has not yet been merged in the main branch.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mario Arias (the-clone-master) wrote : | # |
Hi,
Is there any other step required for getting this merged on main OCB branch ?
Just let me know to proceed...
Thanks
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Stefan Rijnhart (Opener) (stefan-opener) wrote : | # |
To put it simply, it takes more reviewers to deal with all the proposals.
In some cases I would be comfortable with merging a proposal that carry only my own approval when no one else came to support the proposal after some time, but this is not such a trivial change as that so I would really like someone else to approve.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Virgil Dupras (hsoft) wrote : | # |
I just want to say that I'm not ignoring this MP. I will review it, but being unfamiliar with the module and problem domain (cost of goods sold, anglo-saxon vs continental, etc.), I have a lot of catching on to do to be able to do a meaningful review.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mario Arias (the-clone-master) wrote : | # |
Thanks Virgil, Stefan. I know it is hard work to review code...
In case this helps reviewers, this change is already applied to 7.0 and
trunk branches.
I just checked that underline modules had not changed between versions and
then applied the same changes...
If there is anything I can do to help, just let me know.
El 20/09/2013 06:31, "Virgil Dupras" <email address hidden>
escribió:
> I just want to say that I'm not ignoring this MP. I will review it, but
> being unfamiliar with the module and problem domain (cost of goods sold,
> anglo-saxon vs continental, etc.), I have a lot of catching on to do to be
> able to do a meaningful review.
> --
>
> https:/
> You are the owner of
> lp:~the-clone-master/ocb-addons/6.1-lp212930-purchase_anglo_saxon_invoice_from_PO_lines.
>
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mario Arias (the-clone-master) wrote : | # |
Any reviewer that can approve this and merge, please...
It comes from v7/trunk, and is already tested in a couple production systems...
Thanks !!
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Virgil Dupras (hsoft) wrote : | # |
I lack the expertise and time to properly review this MP, but I did like Stefan and compared the diff from the trunk with this MP and they look identical except for the lines 16-19 which aren't in the trunk's diff.
Now it's up to the maintainer of this project to determine whether code-only reviews are sufficient for merging.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Holger Brunn (Therp) (hbrunn) : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Paulius Sladkevičius @ hbee (komsas) wrote : | # |
Hi Mario,
I found that ccount_
Preview Diff
1 | === modified file 'account_anglo_saxon/purchase.py' | |||
2 | --- account_anglo_saxon/purchase.py 2011-12-19 16:54:40 +0000 | |||
3 | +++ account_anglo_saxon/purchase.py 2013-08-16 17:00:41 +0000 | |||
4 | @@ -26,17 +26,17 @@ | |||
5 | 26 | _inherit = "purchase.order" | 26 | _inherit = "purchase.order" |
6 | 27 | _description = "Purchase Order" | 27 | _description = "Purchase Order" |
7 | 28 | 28 | ||
10 | 29 | def _prepare_inv_line(self, cr, uid, account_id, order_line, context=None): | 29 | def _choose_account_from_po_line(self, cr, uid, order_line, context=None): |
11 | 30 | line = super(purchase_order, self)._prepare_inv_line(cr, uid, account_id, order_line, context=context) | 30 | account_id = super(purchase_order, self)._choose_account_from_po_line(cr, uid, order_line, context=context) |
12 | 31 | if order_line.product_id and not order_line.product_id.type == 'service': | 31 | if order_line.product_id and not order_line.product_id.type == 'service': |
13 | 32 | acc_id = order_line.product_id.property_stock_account_input and order_line.product_id.property_stock_account_input.id | 32 | acc_id = order_line.product_id.property_stock_account_input and order_line.product_id.property_stock_account_input.id |
14 | 33 | if not acc_id: | 33 | if not acc_id: |
15 | 34 | acc_id = order_line.product_id.categ_id.property_stock_account_input_categ and order_line.product_id.categ_id.property_stock_account_input_categ.id | 34 | acc_id = order_line.product_id.categ_id.property_stock_account_input_categ and order_line.product_id.categ_id.property_stock_account_input_categ.id |
17 | 35 | if acc_id: | 35 | if not acc_id: |
18 | 36 | raise osv.except_osv(_('Error !'), _('There is no stock input account defined for this product or category: "%s" (id:%d)') % (order_line.product_id.name, order_line.product_id.id,)) | ||
19 | 37 | else: | ||
20 | 36 | fpos = order_line.order_id.fiscal_position or False | 38 | fpos = order_line.order_id.fiscal_position or False |
25 | 37 | new_account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, acc_id) | 39 | account_id = self.pool.get('account.fiscal.position').map_account(cr, uid, fpos, acc_id) |
26 | 38 | line.update({'account_id': new_account_id}) | 40 | return account_id |
23 | 39 | return line | ||
24 | 40 | purchase_order() | ||
27 | 41 | 41 | ||
28 | 42 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: | 42 | # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: |
29 | 43 | 43 | ||
30 | === modified file 'purchase/purchase.py' (properties changed: -x to +x) | |||
31 | --- purchase/purchase.py 2012-10-26 15:32:12 +0000 | |||
32 | +++ purchase/purchase.py 2013-08-16 17:00:41 +0000 | |||
33 | @@ -294,6 +294,20 @@ | |||
34 | 294 | self.write(cr, uid, [id], {'state' : 'confirmed', 'validator' : uid}) | 294 | self.write(cr, uid, [id], {'state' : 'confirmed', 'validator' : uid}) |
35 | 295 | return True | 295 | return True |
36 | 296 | 296 | ||
37 | 297 | def _choose_account_from_po_line(self, cr, uid, po_line, context=None): | ||
38 | 298 | fiscal_obj = self.pool.get('account.fiscal.position') | ||
39 | 299 | property_obj = self.pool.get('ir.property') | ||
40 | 300 | if po_line.product_id: | ||
41 | 301 | acc_id = po_line.product_id.property_account_expense.id | ||
42 | 302 | if not acc_id: | ||
43 | 303 | acc_id = po_line.product_id.categ_id.property_account_expense_categ.id | ||
44 | 304 | if not acc_id: | ||
45 | 305 | raise osv.except_osv(_('Error!'), _('Define expense account for this company: "%s" (id:%d).') % (po_line.product_id.name, po_line.product_id.id,)) | ||
46 | 306 | else: | ||
47 | 307 | acc_id = property_obj.get(cr, uid, 'property_account_expense_categ', 'product.category').id | ||
48 | 308 | fpos = po_line.order_id.fiscal_position or False | ||
49 | 309 | return fiscal_obj.map_account(cr, uid, fpos, acc_id) | ||
50 | 310 | |||
51 | 297 | def _prepare_inv_line(self, cr, uid, account_id, order_line, context=None): | 311 | def _prepare_inv_line(self, cr, uid, account_id, order_line, context=None): |
52 | 298 | """Collects require data from purchase order line that is used to create invoice line | 312 | """Collects require data from purchase order line that is used to create invoice line |
53 | 299 | for that purchase order line | 313 | for that purchase order line |
54 | @@ -338,8 +352,6 @@ | |||
55 | 338 | journal_obj = self.pool.get('account.journal') | 352 | journal_obj = self.pool.get('account.journal') |
56 | 339 | inv_obj = self.pool.get('account.invoice') | 353 | inv_obj = self.pool.get('account.invoice') |
57 | 340 | inv_line_obj = self.pool.get('account.invoice.line') | 354 | inv_line_obj = self.pool.get('account.invoice.line') |
58 | 341 | fiscal_obj = self.pool.get('account.fiscal.position') | ||
59 | 342 | property_obj = self.pool.get('ir.property') | ||
60 | 343 | 355 | ||
61 | 344 | for order in self.browse(cr, uid, ids, context=context): | 356 | for order in self.browse(cr, uid, ids, context=context): |
62 | 345 | pay_acc_id = order.partner_id.property_account_payable.id | 357 | pay_acc_id = order.partner_id.property_account_payable.id |
63 | @@ -351,16 +363,7 @@ | |||
64 | 351 | # generate invoice line correspond to PO line and link that to created invoice (inv_id) and PO line | 363 | # generate invoice line correspond to PO line and link that to created invoice (inv_id) and PO line |
65 | 352 | inv_lines = [] | 364 | inv_lines = [] |
66 | 353 | for po_line in order.order_line: | 365 | for po_line in order.order_line: |
77 | 354 | if po_line.product_id: | 366 | acc_id = self._choose_account_from_po_line(cr, uid, po_line, context=context) |
68 | 355 | acc_id = po_line.product_id.product_tmpl_id.property_account_expense.id | ||
69 | 356 | if not acc_id: | ||
70 | 357 | acc_id = po_line.product_id.categ_id.property_account_expense_categ.id | ||
71 | 358 | if not acc_id: | ||
72 | 359 | raise osv.except_osv(_('Error !'), _('There is no expense account defined for this product: "%s" (id:%d)') % (po_line.product_id.name, po_line.product_id.id,)) | ||
73 | 360 | else: | ||
74 | 361 | acc_id = property_obj.get(cr, uid, 'property_account_expense_categ', 'product.category').id | ||
75 | 362 | fpos = order.fiscal_position or False | ||
76 | 363 | acc_id = fiscal_obj.map_account(cr, uid, fpos, acc_id) | ||
78 | 364 | 367 | ||
79 | 365 | inv_line_data = self._prepare_inv_line(cr, uid, acc_id, po_line, context=context) | 368 | inv_line_data = self._prepare_inv_line(cr, uid, acc_id, po_line, context=context) |
80 | 366 | inv_line_id = inv_line_obj.create(cr, uid, inv_line_data, context=context) | 369 | inv_line_id = inv_line_obj.create(cr, uid, inv_line_data, context=context) |
81 | @@ -539,7 +542,6 @@ | |||
82 | 539 | @param context: A standard dictionary | 542 | @param context: A standard dictionary |
83 | 540 | 543 | ||
84 | 541 | @return: new purchase order id | 544 | @return: new purchase order id |
85 | 542 | |||
86 | 543 | """ | 545 | """ |
87 | 544 | #TOFIX: merged order line should be unlink | 546 | #TOFIX: merged order line should be unlink |
88 | 545 | wf_service = netsvc.LocalService("workflow") | 547 | wf_service = netsvc.LocalService("workflow") |
89 | 546 | 548 | ||
90 | === modified file 'purchase/wizard/purchase_line_invoice.py' (properties changed: -x to +x) | |||
91 | --- purchase/wizard/purchase_line_invoice.py 2011-09-08 09:27:55 +0000 | |||
92 | +++ purchase/wizard/purchase_line_invoice.py 2013-08-16 17:00:41 +0000 | |||
93 | @@ -48,12 +48,11 @@ | |||
94 | 48 | if record_ids: | 48 | if record_ids: |
95 | 49 | res = False | 49 | res = False |
96 | 50 | invoices = {} | 50 | invoices = {} |
103 | 51 | invoice_obj=self.pool.get('account.invoice') | 51 | invoice_obj = self.pool.get('account.invoice') |
104 | 52 | purchase_line_obj=self.pool.get('purchase.order.line') | 52 | purchase_obj = self.pool.get('purchase.order') |
105 | 53 | property_obj=self.pool.get('ir.property') | 53 | purchase_line_obj = self.pool.get('purchase.order.line') |
106 | 54 | account_fiscal_obj=self.pool.get('account.fiscal.position') | 54 | invoice_line_obj = self.pool.get('account.invoice.line') |
107 | 55 | invoice_line_obj=self.pool.get('account.invoice.line') | 55 | account_jrnl_obj = self.pool.get('account.journal') |
102 | 56 | account_jrnl_obj=self.pool.get('account.journal') | ||
108 | 57 | 56 | ||
109 | 58 | def multiple_order_invoice_notes(orders): | 57 | def multiple_order_invoice_notes(orders): |
110 | 59 | notes = "" | 58 | notes = "" |
111 | @@ -62,7 +61,6 @@ | |||
112 | 62 | return notes | 61 | return notes |
113 | 63 | 62 | ||
114 | 64 | 63 | ||
115 | 65 | |||
116 | 66 | def make_invoice_by_partner(partner, orders, lines_ids): | 64 | def make_invoice_by_partner(partner, orders, lines_ids): |
117 | 67 | """ | 65 | """ |
118 | 68 | create a new invoice for one supplier | 66 | create a new invoice for one supplier |
119 | @@ -99,37 +97,16 @@ | |||
120 | 99 | order.write({'invoice_ids': [(4, inv_id)]}) | 97 | order.write({'invoice_ids': [(4, inv_id)]}) |
121 | 100 | return inv_id | 98 | return inv_id |
122 | 101 | 99 | ||
125 | 102 | for line in purchase_line_obj.browse(cr,uid,record_ids): | 100 | for line in purchase_line_obj.browse(cr, uid, record_ids, context=context): |
126 | 103 | if (not line.invoiced) and (line.state not in ('draft','cancel')): | 101 | if (not line.invoiced) and (line.state not in ('draft', 'cancel')): |
127 | 104 | if not line.partner_id.id in invoices: | 102 | if not line.partner_id.id in invoices: |
128 | 105 | invoices[line.partner_id.id] = [] | 103 | invoices[line.partner_id.id] = [] |
156 | 106 | if line.product_id: | 104 | |
157 | 107 | a = line.product_id.product_tmpl_id.property_account_expense.id | 105 | acc_id = purchase_obj._choose_account_from_po_line(cr, uid, line, context=context) |
158 | 108 | if not a: | 106 | inv_line_data = purchase_obj._prepare_inv_line(cr, uid, acc_id, line, context=context) |
159 | 109 | a = line.product_id.categ_id.property_account_expense_categ.id | 107 | inv_line_data.update({'origin': line.order_id.name}) |
160 | 110 | if not a: | 108 | inv_id = invoice_line_obj.create(cr, uid, inv_line_data, context=context) |
161 | 111 | raise osv.except_osv(_('Error !'), | 109 | |
135 | 112 | _('There is no expense account defined ' \ | ||
136 | 113 | 'for this product: "%s" (id:%d)') % \ | ||
137 | 114 | (line.product_id.name, line.product_id.id,)) | ||
138 | 115 | else: | ||
139 | 116 | a = property_obj.get(cr, uid, | ||
140 | 117 | 'property_account_expense_categ', 'product.category', | ||
141 | 118 | context=context).id | ||
142 | 119 | fpos = line.order_id.fiscal_position or False | ||
143 | 120 | a = account_fiscal_obj.map_account(cr, uid, fpos, a) | ||
144 | 121 | inv_id = invoice_line_obj.create(cr, uid, { | ||
145 | 122 | 'name': line.name, | ||
146 | 123 | 'origin': line.order_id.name, | ||
147 | 124 | 'account_id': a, | ||
148 | 125 | 'price_unit': line.price_unit, | ||
149 | 126 | 'quantity': line.product_qty, | ||
150 | 127 | 'uos_id': line.product_uom.id, | ||
151 | 128 | 'product_id': line.product_id.id or False, | ||
152 | 129 | 'invoice_line_tax_id': [(6, 0, [x.id for x in line.taxes_id])], | ||
153 | 130 | 'note': line.notes, | ||
154 | 131 | 'account_analytic_id': line.account_analytic_id and line.account_analytic_id.id or False, | ||
155 | 132 | }) | ||
162 | 133 | purchase_line_obj.write(cr, uid, [line.id], {'invoiced': True, 'invoice_lines': [(4, inv_id)]}) | 110 | purchase_line_obj.write(cr, uid, [line.id], {'invoiced': True, 'invoice_lines': [(4, inv_id)]}) |
163 | 134 | invoices[line.partner_id.id].append((line,inv_id)) | 111 | invoices[line.partner_id.id].append((line,inv_id)) |
164 | 135 | 112 |
Oppss... correct bug related to this branch is lp:1212930... I skipped the first "1" when reporting...