Merge lp:~the-clone-master/ocb-addons/6.1-lp212930-purchase_anglo_saxon_invoice_from_PO_lines into lp:ocb-addons/6.1

Proposed by Mario Arias
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
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: mp+180621@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Mario Arias (the-clone-master) wrote :

Oppss... correct bug related to this branch is lp:1212930... I skipped the first "1" when reporting...

Revision history for this message
Stefan Rijnhart (Opener) (stefan-opener) wrote :

Hi Mario,

Great work! I verified that the diff is equivalent to http://bazaar.launchpad.net/~openerp/openobject-addons/trunk/revision/8787, and that the relevant sections of the files involved have not been changed in trunk in a significant way ever since.

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://bazaar.launchpad.net/~openerp/openobject-addons/7.0/revision/9293

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.

review: Approve (code review)
Revision history for this message
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://bazaar.launchpad.net/~openerp/openobject-addons/trunk/revision/8787, and that the relevant sections of the files involved have not been changed in trunk in a significant way ever since.
>
> 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://bazaar.launchpad.net/~openerp/openobject-addons/7.0/revision/9293
>
> 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.

Revision history for this message
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

Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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://code.launchpad.net/~the-clone-master/ocb-addons/6.1-lp212930-purchase_anglo_saxon_invoice_from_PO_lines/+merge/180621
> You are the owner of
> lp:~the-clone-master/ocb-addons/6.1-lp212930-purchase_anglo_saxon_invoice_from_PO_lines.
>

Revision history for this message
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 !!

Revision history for this message
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.

review: Approve
Revision history for this message
Holger Brunn (Therp) (hbrunn) :
review: Approve (code review)
Revision history for this message
Paulius Sladkevičius @ hbee (komsas) wrote :

Hi Mario,

I found that ccount_anglo_saxon/purchase.py have a bug import is missing: from tools.translate import _

review: Needs Fixing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'account_anglo_saxon/purchase.py'
--- account_anglo_saxon/purchase.py 2011-12-19 16:54:40 +0000
+++ account_anglo_saxon/purchase.py 2013-08-16 17:00:41 +0000
@@ -26,17 +26,17 @@
26 _inherit = "purchase.order"26 _inherit = "purchase.order"
27 _description = "Purchase Order"27 _description = "Purchase Order"
2828
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):
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)
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':
32 acc_id = order_line.product_id.property_stock_account_input and order_line.product_id.property_stock_account_input.id32 acc_id = order_line.product_id.property_stock_account_input and order_line.product_id.property_stock_account_input.id
33 if not acc_id:33 if not acc_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.id34 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
35 if acc_id:35 if not acc_id:
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,))
37 else:
36 fpos = order_line.order_id.fiscal_position or False38 fpos = order_line.order_id.fiscal_position or False
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)
38 line.update({'account_id': new_account_id})40 return account_id
39 return line
40purchase_order()
4141
42# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:42# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
4343
=== modified file 'purchase/purchase.py' (properties changed: -x to +x)
--- purchase/purchase.py 2012-10-26 15:32:12 +0000
+++ purchase/purchase.py 2013-08-16 17:00:41 +0000
@@ -294,6 +294,20 @@
294 self.write(cr, uid, [id], {'state' : 'confirmed', 'validator' : uid})294 self.write(cr, uid, [id], {'state' : 'confirmed', 'validator' : uid})
295 return True295 return True
296296
297 def _choose_account_from_po_line(self, cr, uid, po_line, context=None):
298 fiscal_obj = self.pool.get('account.fiscal.position')
299 property_obj = self.pool.get('ir.property')
300 if po_line.product_id:
301 acc_id = po_line.product_id.property_account_expense.id
302 if not acc_id:
303 acc_id = po_line.product_id.categ_id.property_account_expense_categ.id
304 if not acc_id:
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,))
306 else:
307 acc_id = property_obj.get(cr, uid, 'property_account_expense_categ', 'product.category').id
308 fpos = po_line.order_id.fiscal_position or False
309 return fiscal_obj.map_account(cr, uid, fpos, acc_id)
310
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):
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
299 for that purchase order line313 for that purchase order line
@@ -338,8 +352,6 @@
338 journal_obj = self.pool.get('account.journal')352 journal_obj = self.pool.get('account.journal')
339 inv_obj = self.pool.get('account.invoice')353 inv_obj = self.pool.get('account.invoice')
340 inv_line_obj = self.pool.get('account.invoice.line')354 inv_line_obj = self.pool.get('account.invoice.line')
341 fiscal_obj = self.pool.get('account.fiscal.position')
342 property_obj = self.pool.get('ir.property')
343355
344 for order in self.browse(cr, uid, ids, context=context):356 for order in self.browse(cr, uid, ids, context=context):
345 pay_acc_id = order.partner_id.property_account_payable.id357 pay_acc_id = order.partner_id.property_account_payable.id
@@ -351,16 +363,7 @@
351 # generate invoice line correspond to PO line and link that to created invoice (inv_id) and PO line363 # generate invoice line correspond to PO line and link that to created invoice (inv_id) and PO line
352 inv_lines = []364 inv_lines = []
353 for po_line in order.order_line:365 for po_line in order.order_line:
354 if po_line.product_id:366 acc_id = self._choose_account_from_po_line(cr, uid, po_line, context=context)
355 acc_id = po_line.product_id.product_tmpl_id.property_account_expense.id
356 if not acc_id:
357 acc_id = po_line.product_id.categ_id.property_account_expense_categ.id
358 if not acc_id:
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,))
360 else:
361 acc_id = property_obj.get(cr, uid, 'property_account_expense_categ', 'product.category').id
362 fpos = order.fiscal_position or False
363 acc_id = fiscal_obj.map_account(cr, uid, fpos, acc_id)
364367
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)
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)
@@ -539,7 +542,6 @@
539 @param context: A standard dictionary542 @param context: A standard dictionary
540543
541 @return: new purchase order id544 @return: new purchase order id
542
543 """545 """
544 #TOFIX: merged order line should be unlink546 #TOFIX: merged order line should be unlink
545 wf_service = netsvc.LocalService("workflow")547 wf_service = netsvc.LocalService("workflow")
546548
=== modified file 'purchase/wizard/purchase_line_invoice.py' (properties changed: -x to +x)
--- purchase/wizard/purchase_line_invoice.py 2011-09-08 09:27:55 +0000
+++ purchase/wizard/purchase_line_invoice.py 2013-08-16 17:00:41 +0000
@@ -48,12 +48,11 @@
48 if record_ids:48 if record_ids:
49 res = False49 res = False
50 invoices = {}50 invoices = {}
51 invoice_obj=self.pool.get('account.invoice')51 invoice_obj = self.pool.get('account.invoice')
52 purchase_line_obj=self.pool.get('purchase.order.line')52 purchase_obj = self.pool.get('purchase.order')
53 property_obj=self.pool.get('ir.property')53 purchase_line_obj = self.pool.get('purchase.order.line')
54 account_fiscal_obj=self.pool.get('account.fiscal.position')54 invoice_line_obj = self.pool.get('account.invoice.line')
55 invoice_line_obj=self.pool.get('account.invoice.line')55 account_jrnl_obj = self.pool.get('account.journal')
56 account_jrnl_obj=self.pool.get('account.journal')
5756
58 def multiple_order_invoice_notes(orders):57 def multiple_order_invoice_notes(orders):
59 notes = ""58 notes = ""
@@ -62,7 +61,6 @@
62 return notes61 return notes
6362
6463
65
66 def make_invoice_by_partner(partner, orders, lines_ids):64 def make_invoice_by_partner(partner, orders, lines_ids):
67 """65 """
68 create a new invoice for one supplier66 create a new invoice for one supplier
@@ -99,37 +97,16 @@
99 order.write({'invoice_ids': [(4, inv_id)]})97 order.write({'invoice_ids': [(4, inv_id)]})
100 return inv_id98 return inv_id
10199
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):
103 if (not line.invoiced) and (line.state not in ('draft','cancel')):101 if (not line.invoiced) and (line.state not in ('draft', 'cancel')):
104 if not line.partner_id.id in invoices:102 if not line.partner_id.id in invoices:
105 invoices[line.partner_id.id] = []103 invoices[line.partner_id.id] = []
106 if line.product_id:104
107 a = line.product_id.product_tmpl_id.property_account_expense.id105 acc_id = purchase_obj._choose_account_from_po_line(cr, uid, line, context=context)
108 if not a:106 inv_line_data = purchase_obj._prepare_inv_line(cr, uid, acc_id, line, context=context)
109 a = line.product_id.categ_id.property_account_expense_categ.id107 inv_line_data.update({'origin': line.order_id.name})
110 if not a:108 inv_id = invoice_line_obj.create(cr, uid, inv_line_data, context=context)
111 raise osv.except_osv(_('Error !'),109
112 _('There is no expense account defined ' \
113 'for this product: "%s" (id:%d)') % \
114 (line.product_id.name, line.product_id.id,))
115 else:
116 a = property_obj.get(cr, uid,
117 'property_account_expense_categ', 'product.category',
118 context=context).id
119 fpos = line.order_id.fiscal_position or False
120 a = account_fiscal_obj.map_account(cr, uid, fpos, a)
121 inv_id = invoice_line_obj.create(cr, uid, {
122 'name': line.name,
123 'origin': line.order_id.name,
124 'account_id': a,
125 'price_unit': line.price_unit,
126 'quantity': line.product_qty,
127 'uos_id': line.product_uom.id,
128 'product_id': line.product_id.id or False,
129 'invoice_line_tax_id': [(6, 0, [x.id for x in line.taxes_id])],
130 'note': line.notes,
131 'account_analytic_id': line.account_analytic_id and line.account_analytic_id.id or False,
132 })
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)]})
134 invoices[line.partner_id.id].append((line,inv_id))111 invoices[line.partner_id.id].append((line,inv_id))
135112

Subscribers

People subscribed via source and target branches