[6.0] Error related with analytic accounts creating a sales invoice from picking that come from sales order with services

Bug #741947 reported by Sebastán Jara
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Odoo Addons (MOVED TO GITHUB)
Incomplete
Undecided
Unassigned

Bug Description

Environment: at stable 6.0 version, with installed modules "base", "stock", "sale", "purchase" and "analytic". Important: the modules "account_analytic_default" and "account_analytic_plans" must be not installed.

If you try to create a sales invoice from picking that comes to a sales order that contains services and stockable products, the next error occurs: Field 'purchase_line_id' does not exist in object 'browse_record(sale.order.line, 5)'

The origin of this error really is the "sale" module, when try to add the services lines into invoice, at method "action_invoice_create" from file "stock.py", in particular at method "_get_account_analytic_invoice". The problem is the fourth parameter "sale_line" passed to this funtion: account_analytic_id = self._get_account_analytic_invoice(cursor, user, picking, sale_line) .... because this parameter must be a "stock_move" object, and really is passed a "sale_order_line" object.

But the solution involves:
  (1) the module "purchase", because also inherits the method "_get_account_analytic_invoice" from "stock_picking" class. And when execute this method, a "stock_move" object is expected, but a "sale_order_line object" is passed, and the error occurs.
  (2) the module "account_analytic_default", if has installed after. The reason are the same: inherits the method "_get_account_analytic_invoice" from "stock_picking" class.

These are the corrections that I've applied to fix the bug:

  (1) At file "stock.py" from addon "sale", at function "def action_invoice_create":
  - account_analytic_id = self._get_account_analytic_invoice(cursor, user, picking, sale_line)
  + account_analytic_id = self._get_account_analytic_invoice(cursor, user, picking, None)

  2) At file "stock.py" from addon "purchase", at function "def _get_account_analytic_invoice":
  - if move_line.purchase_line_id:
  + if move_line and move_line.purchase_line_id:

  3) At file "account_analytic_default.py" from addon "account_analytic_default", at function "def _get_account_analytic_invoice":
  - rec = self.pool.get('account.analytic.default').account_get(cursor, user, move_line.product_id.id, partner_id and partner_id.id, user, time.strftime('%Y-%m-%d'), context={})
  + product_id = False or move_line and move_line.product_id.id
  + rec = self.pool.get('account.analytic.default').account_get(cursor, user, product_id, partner_id and partner_id.id, user, time.strftime('%Y-%m-%d'), context={})

I hope it's useful for you.

Revision history for this message
Sebastán Jara (sebas-jara-bravo) wrote :
Revision history for this message
Azazahmed Saiyed (OpenERP) (saz-openerp) wrote :

Hello,

I have tested the scenario but did not able to meet with the traceback. I have attached the screen shot for the reference, So please refer it and notify us if problem still persists at your end.

Thanks.

Changed in openobject-addons:
status: New → Incomplete
Revision history for this message
Sebastán Jara (sebas-jara-bravo) wrote :

Hi Azazahmed.

Can you show me the invoice lines?

Thanks.

Changed in openobject-addons:
status: Incomplete → New
Revision history for this message
Azazahmed Saiyed (OpenERP) (saz-openerp) wrote :

Hello,

I have attached the screen shots of resultant customer invoice's both views. Please refer it and reply to us for further qualification.

Thanks.

Revision history for this message
Azazahmed Saiyed (OpenERP) (saz-openerp) wrote :
Revision history for this message
Sebastán Jara (sebas-jara-bravo) wrote :

Hi again.

I've verified that your invoice is OK, but the problem still persist in my installation. My version is the first stable 6.0 uploaded at www.openerp.com (now, the actual version at www.openerp.com is 6.0.2)

What version have you installed?

Thanks

Revision history for this message
Azazahmed Saiyed (OpenERP) (saz-openerp) wrote :

Hello,

If possible then would you please attach your dump DB for testing it at my end. Please check it with the latest stable version 6.0.2 also.

Thanks.

Revision history for this message
Amit Parik (amit-parik) wrote :

Hello,

I have checked your issue with latest trunk and stable both at my end but all are working as expected and I did not get any type of the traceback.

I have attached a video for your reference, So would you please check it and notify me where you faced the problem.

Waiting for your reply!

Thanks in advance!

Revision history for this message
Amit Parik (amit-parik) wrote :
Changed in openobject-addons:
status: New → Incomplete
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.