Merge lp:~openerp-dev/openobject-addons/7.0-opw-590096-ado into lp:openobject-addons/7.0

Proposed by Amit Dodiya (OpenERP)
Status: Merged
Approved by: Naresh(OpenERP)
Approved revision: no longer in the source branch.
Merged at revision: 9314
Proposed branch: lp:~openerp-dev/openobject-addons/7.0-opw-590096-ado
Merge into: lp:openobject-addons/7.0
Diff against target: 19 lines (+5/-1)
1 file modified
account/account_invoice.py (+5/-1)
To merge this branch: bzr merge lp:~openerp-dev/openobject-addons/7.0-opw-590096-ado
Reviewer Review Type Date Requested Status
Martin Trigaux (OpenERP) (community) Approve
Amit Dodiya (OpenERP) (community) Needs Resubmitting
Lorenzo Battistini (community) Needs Information
Naresh(OpenERP) (community) Approve
Xavier ALT Pending
Review via email: mp+156520@code.launchpad.net

Description of the change

Hello,

[FIX] account_invoice: due date is reset to current date when we have no payment term and due date is manually defined

Steps:
1). Install accounting module with demo data
2). Create a customer invoice without payment terms
3). Now go to the second tab to set manually the due date (pick up one of you choice which is not today)
Validate the invoice.
Problem : the due date is reset to today date

Regards,
Amit

To post a comment you must log in.
Revision history for this message
Naresh(OpenERP) (nch-openerp) wrote :

Its nice to fallback to invoice date at last .

Thanks,
Naresh Soni
OpenERP Enterprise Services

review: Approve
Revision history for this message
Lorenzo Battistini (elbati) wrote :

Why 'inv_record' gets 'ids' and it's not a list?

review: Needs Information
Revision history for this message
Balaji Kannan (bkannan) wrote :
Download full text (3.9 KiB)

If Invoice is generated from the Sale order, we get an error:

Server Traceback (most recent call last):
  File "/opt/openerp/web/addons/web/session.py", line 90, in send
    return openerp.netsvc.dispatch_rpc(service_name, method, args)
  File "/opt/openerp/server/openerp/netsvc.py", line 293, in dispatch_rpc
    result = ExportService.getService(service_name).dispatch(method, params)
  File "/opt/openerp/server/openerp/service/web_services.py", line 626, in dispatch
    res = fn(db, uid, *params)
  File "/opt/openerp/server/openerp/osv/osv.py", line 188, in execute_kw
    return self.execute(db, uid, obj, method, *args, **kw or {})
  File "/opt/openerp/server/openerp/osv/osv.py", line 131, in wrapper
    return f(self, dbname, *args, **kwargs)
  File "/opt/openerp/server/openerp/osv/osv.py", line 197, in execute
    res = self.execute_cr(cr, uid, obj, method, *args, **kw)
  File "/opt/openerp/addons/audittrail/audittrail.py", line 514, in execute_cr
    return fct_src(cr, uid, model, method, *args, **kw)
  File "/opt/openerp/server/openerp/osv/osv.py", line 185, in execute_cr
    return getattr(object, method)(cr, uid, *args, **kw)
  File "/opt/openerp/addons/sale/wizard/sale_make_invoice_advance.py", line 170, in create_invoices
    res = sale_obj.manual_invoice(cr, uid, sale_ids, context)
  File "/opt/openerp/addons/sale/sale.py", line 435, in manual_invoice
    wf_service.trg_validate(uid, 'sale.order', id, 'manual_invoice', cr)
  File "/opt/openerp/server/openerp/workflow/wkf_service.py", line 119, in trg_validate
    res2 = instance.validate(cr, id, ident, signal)
  File "/opt/openerp/server/openerp/workflow/instance.py", line 43, in validate
    workitem.process(cr, witem, ident, signal, force_running, stack=stack)
  File "/opt/openerp/server/openerp/workflow/workitem.py", line 60, in process
    ok = _split_test(cr, workitem, activity['split_mode'], ident, signal, stack)
  File "/opt/openerp/server/openerp/workflow/workitem.py", line 175, in _split_test
    _join_test(cr, t[0], t[1], ident, stack)
  File "/opt/openerp/server/openerp/workflow/workitem.py", line 183, in _join_test
    create(cr,[activity], inst_id, ident, stack)
  File "/opt/openerp/server/openerp/workflow/workitem.py", line 40, in create
    process(cr, res, ident, stack=stack)
  File "/opt/openerp/server/openerp/workflow/workitem.py", line 52, in process
    result = _execute(cr, workitem, activity, ident, stack)
  File "/opt/openerp/server/openerp/workflow/workitem.py", line 127, in _execute
    id_new = wkf_expr.execute(cr, ident, workitem, activity)
  File "/opt/openerp/server/openerp/workflow/wkf_expr.py", line 67, in execute
    return _eval_expr(cr, ident, workitem, activity['action'])
  File "/opt/openerp/server/openerp/workflow/wkf_expr.py", line 57, in _eval_expr
    ret = eval(line, env, nocopy=True)
  File "/opt/openerp/server/openerp/tools/safe_eval.py", line 241, in safe_eval
    return eval(test_expr(expr, _SAFE_OPCODES, mode=mode), globals_dict, locals_dict)
  File "", line 1, in <module>
  File "/opt/openerp/server/openerp/osv/orm.py", line 374, in function_proxy
    return attr(self._cr, self._uid, [self._id], *args, **kwargs)
  File "/opt/openerp/ad...

Read more...

Revision history for this message
Balaji Kannan (bkannan) wrote :

Changing inv_record.date_due to inv_record[0].date_due works. Is this the correct fix?

Revision history for this message
Amit Dodiya (OpenERP) (ado-openerp) wrote :

Hello,

I have changed the code.

Regards,
Amit

review: Needs Resubmitting
Revision history for this message
Rifakat Husen (OpenERP) (rha-openerp) wrote :

Amit, I this needs a bit more optimization which I have done in my last commit.
What I did,
- (int, long) instead of int in isinstance() check
- when there is payment_term_id in that case for loop and browse() call is useless so better
  need to check existance of payment_term_id first
- I think we don't need to two saperate `if`, only one outside for loop `if not payment_term_id` should
  work when you return like,
  return {'value':{'date_due': inv.date_due and inv.date_due or date_invoice}}

Thanks for your work,
Rifakat

Revision history for this message
Martin Trigaux (OpenERP) (mat-openerp) wrote :

LGTM. Merged into 7.0.
revno: 9314 [merge]
revision-id: <email address hidden>

Thanks for the patch and reviews.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'account/account_invoice.py'
2--- account/account_invoice.py 2013-06-12 15:38:14 +0000
3+++ account/account_invoice.py 2013-07-12 07:08:29 +0000
4@@ -560,10 +560,14 @@
5
6 def onchange_payment_term_date_invoice(self, cr, uid, ids, payment_term_id, date_invoice):
7 res = {}
8+ if isinstance(ids, (int, long)):
9+ ids = [ids]
10 if not date_invoice:
11 date_invoice = time.strftime('%Y-%m-%d')
12 if not payment_term_id:
13- return {'value':{'date_due': date_invoice}} #To make sure the invoice has a due date when no payment term
14+ inv = self.browse(cr, uid, ids[0])
15+ #To make sure the invoice due date should contain due date which is entered by user when there is no payment term defined
16+ return {'value':{'date_due': inv.date_due and inv.date_due or date_invoice}}
17 pterm_list = self.pool.get('account.payment.term').compute(cr, uid, payment_term_id, value=1, date_ref=date_invoice)
18 if pterm_list:
19 pterm_list = [line[0] for line in pterm_list]