From 988ad9ccc978bfd6f2aee0f17728ad38f16b1a6c Mon Sep 17 00:00:00 2001 From: "vda (Open ERP)" Date: Wed, 10 Nov 2010 12:48:32 +0530 Subject: [PATCH 01/30] [IMP] Share web addon. bzr revid: vda@tinyerp.com-20101110071832-ftzgmrd3trsz0icr --- addons/share/__openerp__.py | 2 ++ addons/share/web/__init__.py | 2 ++ addons/share/web/controllers.py | 37 +++++++++++++++++++++++++++ addons/share/web/editors.py | 44 +++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+) create mode 100644 addons/share/web/__init__.py create mode 100644 addons/share/web/controllers.py create mode 100644 addons/share/web/editors.py diff --git a/addons/share/__openerp__.py b/addons/share/__openerp__.py index 21b63fd3bc1..393afb9717b 100644 --- a/addons/share/__openerp__.py +++ b/addons/share/__openerp__.py @@ -48,6 +48,8 @@ 'wizard/share_wizard_view.xml' ], 'installable': True, + 'active': False, + 'web': True, } # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/share/web/__init__.py b/addons/share/web/__init__.py new file mode 100644 index 00000000000..f95bb222c10 --- /dev/null +++ b/addons/share/web/__init__.py @@ -0,0 +1,2 @@ +import controllers +import editors \ No newline at end of file diff --git a/addons/share/web/controllers.py b/addons/share/web/controllers.py new file mode 100644 index 00000000000..c658a3eede5 --- /dev/null +++ b/addons/share/web/controllers.py @@ -0,0 +1,37 @@ +import urlparse + +import cherrypy + +from openobject.tools import expose, ast +import openerp.controllers +from openerp.controllers import actions +from openerp.utils import rpc, TinyDict + +class Piratepad(openerp.controllers.SecuredController): + _cp_path = "/share" + + @expose() + def index(self, **kw): + domain = ast.literal_eval(kw['domain']) + search_domain = ast.literal_eval(kw['search_domain']) + filter_domain = ast.literal_eval(kw['filter_domain']) + + context = ast.literal_eval(kw['context']) + view_name = context.get('_terp_view_name') + + domain.extend(search_domain) + + action_id = rpc.RPCProxy('ir.actions.actions').search([('name','=',view_name)], 0, 0, 0, context) + if action_id: + action_id = action_id[0] + + model = 'share.wizard' + proxy = rpc.RPCProxy(model) + + share_wiz_id = rpc.RPCProxy('ir.ui.menu').search([('name','=', 'Share Wizard')]) + context.update({'active_ids': share_wiz_id, 'active_id': share_wiz_id[0], '_terp_view_name': 'Share Wizard'}) + data = {'domain': str(domain), 'action_id':action_id} + id = proxy.create(data, context) + res = rpc.session.execute('object', 'execute', model, 'go_step_1', [id], context) + return actions.execute(res, ids=[id]) + diff --git a/addons/share/web/editors.py b/addons/share/web/editors.py new file mode 100644 index 00000000000..b55afbf0896 --- /dev/null +++ b/addons/share/web/editors.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +import openobject.templating + +class SidebarTemplateEditor(openobject.templating.TemplateEditor): + templates = ['/openerp/widgets/templates/sidebar.mako'] + ADD_SHARE_BUTTON = u'id="sidebar"' + + def insert_share_link(self, output): + # Insert the link on the line right after the link to open the + # attachment form + form_opener_insertion = output.index( + '\n', + output.index(self.ADD_SHARE_BUTTON)) + 1 + output = output[:form_opener_insertion] + \ + '''

${_("Share View")}

+ + + \n''' + \ + output[form_opener_insertion:] + return output + + def edit(self, template, template_text): + output = super(SidebarTemplateEditor, self).edit(template, template_text) + + output = self.insert_share_link(output) + return output \ No newline at end of file From 15f8f81e0568ebbf3ab303f9c22e023a23b96ada Mon Sep 17 00:00:00 2001 From: "vda (Open ERP)" Date: Mon, 15 Nov 2010 16:07:06 +0530 Subject: [PATCH 02/30] [FIX] Improved share action method,share url and passed active db in email. bzr revid: vda@tinyerp.com-20101115103706-vhkrxbnrw73sljmr --- addons/share/__openerp__.py | 1 - addons/share/web/controllers.py | 50 +++++++++++++---------------- addons/share/web/editors.py | 16 ++++----- addons/share/wizard/share_wizard.py | 1 + 4 files changed, 30 insertions(+), 38 deletions(-) diff --git a/addons/share/__openerp__.py b/addons/share/__openerp__.py index 393afb9717b..768d24974a5 100644 --- a/addons/share/__openerp__.py +++ b/addons/share/__openerp__.py @@ -48,7 +48,6 @@ 'wizard/share_wizard_view.xml' ], 'installable': True, - 'active': False, 'web': True, } diff --git a/addons/share/web/controllers.py b/addons/share/web/controllers.py index c658a3eede5..18ed74a2d5e 100644 --- a/addons/share/web/controllers.py +++ b/addons/share/web/controllers.py @@ -1,37 +1,33 @@ -import urlparse +from openobject.tools import expose, ast +from openerp.controllers import actions +from openerp.utils import rpc +import openerp.controllers import cherrypy -from openobject.tools import expose, ast -import openerp.controllers -from openerp.controllers import actions -from openerp.utils import rpc, TinyDict + class Piratepad(openerp.controllers.SecuredController): _cp_path = "/share" @expose() - def index(self, **kw): - domain = ast.literal_eval(kw['domain']) - search_domain = ast.literal_eval(kw['search_domain']) - filter_domain = ast.literal_eval(kw['filter_domain']) - - context = ast.literal_eval(kw['context']) - view_name = context.get('_terp_view_name') - + def index(self, domain, search_domain, context, name): + domain = ast.literal_eval(domain) + search_domain = ast.literal_eval(search_domain) domain.extend(search_domain) - action_id = rpc.RPCProxy('ir.actions.actions').search([('name','=',view_name)], 0, 0, 0, context) - if action_id: - action_id = action_id[0] - - model = 'share.wizard' - proxy = rpc.RPCProxy(model) - - share_wiz_id = rpc.RPCProxy('ir.ui.menu').search([('name','=', 'Share Wizard')]) - context.update({'active_ids': share_wiz_id, 'active_id': share_wiz_id[0], '_terp_view_name': 'Share Wizard'}) - data = {'domain': str(domain), 'action_id':action_id} - id = proxy.create(data, context) - res = rpc.session.execute('object', 'execute', model, 'go_step_1', [id], context) - return actions.execute(res, ids=[id]) - + context = ast.literal_eval(context) + view_name = context.get('_terp_view_name') or name + if view_name: + action_id = rpc.RPCProxy('ir.actions.actions').search([('name','=',view_name)], 0, 0, 0, context) + if action_id: + action_id = action_id[0] + share_model = 'share.wizard' + share_root_url = cherrypy.config.get('server.socket_host') + ':' + str(cherrypy.config.get('server.socket_port')) + + share_wiz_id = rpc.RPCProxy('ir.ui.menu').search([('name','=', 'Share Wizard')]) + context.update({'active_ids': share_wiz_id, 'active_id': share_wiz_id[0], '_terp_view_name': 'Share Wizard', 'share_root_url': share_root_url}) + sharing_view_id = rpc.RPCProxy(share_model).create({'domain': str(domain), 'action_id':action_id}, context) + + return actions.execute(rpc.session.execute('object', 'execute', share_model, 'go_step_1', [sharing_view_id], context), ids=[sharing_view_id], context=context) + diff --git a/addons/share/web/editors.py b/addons/share/web/editors.py index b55afbf0896..fadbe50ff72 100644 --- a/addons/share/web/editors.py +++ b/addons/share/web/editors.py @@ -12,24 +12,20 @@ class SidebarTemplateEditor(openobject.templating.TemplateEditor): '\n', output.index(self.ADD_SHARE_BUTTON)) + 1 output = output[:form_opener_insertion] + \ - '''

${_("Share View")}

+ '''

${_("Sharing")}

@@ -41,4 +37,4 @@ class SidebarTemplateEditor(openobject.templating.TemplateEditor): output = super(SidebarTemplateEditor, self).edit(template, template_text) output = self.insert_share_link(output) - return output \ No newline at end of file + return output diff --git a/addons/share/wizard/share_wizard.py b/addons/share/wizard/share_wizard.py index 9349980933f..4943f6a6e10 100644 --- a/addons/share/wizard/share_wizard.py +++ b/addons/share/wizard/share_wizard.py @@ -427,6 +427,7 @@ class share_create(osv.osv_memory): body += _("You may use the following login and password to get access to this protected area:") + "\n" body += "%s: %s" % (_("Username"), result_line.login) + "\n" body += "%s: %s" % (_("Password"), result_line.password) + "\n" + body += "%s: %s" % (_("Database"), cr.dbname) + "\n" else: body += _("This additional data has been automatically added to your current access.\n") body += _("You may use your existing login and password to view it. As a reminder, your login is %s.\n") % result_line.login From dd50d55b8d283934c2cb97849790a4da8c1f9c9b Mon Sep 17 00:00:00 2001 From: mtr Date: Thu, 18 Nov 2010 13:57:59 +0530 Subject: [PATCH 03/30] [IMP] Account: Partner Ledger Report-cummulative balance bzr revid: mtr@mtr-20101118082759-3sztv3si7sc5kztj --- addons/account/report/account_journal.py | 1 + addons/account/report/account_partner_ledger.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/addons/account/report/account_journal.py b/addons/account/report/account_journal.py index 82af01cdb0b..9bf5b026206 100644 --- a/addons/account/report/account_journal.py +++ b/addons/account/report/account_journal.py @@ -120,6 +120,7 @@ class journal_print(report_sxw.rml_parse, common_report_header): self.cr.execute('SELECT l.id FROM account_move_line l, account_move am WHERE l.move_id=am.id AND am.state IN %s AND l.period_id=%s AND l.journal_id IN %s ' + self.query_get_clause + ' ORDER BY l.'+ self.sort_selection + '',(tuple(move_state), period_id, tuple(journal_id) )) ids = map(lambda x: x[0], self.cr.fetchall()) + print"--ids--",ids return obj_mline.browse(self.cr, self.uid, ids) def _set_get_account_currency_code(self, account_id): diff --git a/addons/account/report/account_partner_ledger.py b/addons/account/report/account_partner_ledger.py index e66c3a9d523..79ae0ce83cf 100644 --- a/addons/account/report/account_partner_ledger.py +++ b/addons/account/report/account_partner_ledger.py @@ -152,8 +152,10 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header): (partner.id, tuple(self.account_ids), tuple(move_state))) res = self.cr.dictfetchall() sum = 0.0 + if self.initial_balance: + sum = self.init_bal_sum for r in res: - sum = r['debit'] - r['credit'] + sum += r['debit'] - r['credit'] r['progress'] = sum full_account.append(r) return full_account @@ -178,7 +180,9 @@ class third_party_ledger(report_sxw.rml_parse, common_report_header): " " + RECONCILE_TAG + " "\ "AND " + self.init_query + " ", (partner.id, tuple(move_state), tuple(self.account_ids))) - return self.cr.fetchall() + res = self.cr.fetchall() + self.init_bal_sum = res[0][2] + return res def _sum_debit_partner(self, partner): move_state = ['draft','posted'] From f6616b83a664df826c62d7b34ccb98e5de353297 Mon Sep 17 00:00:00 2001 From: mtr Date: Fri, 19 Nov 2010 10:23:49 +0530 Subject: [PATCH 04/30] [IMP] Account:removed the print statement bzr revid: mtr@mtr-20101119045349-v1ww46vd0vkixz6m --- addons/account/report/account_journal.py | 1 - 1 file changed, 1 deletion(-) diff --git a/addons/account/report/account_journal.py b/addons/account/report/account_journal.py index 9bf5b026206..82af01cdb0b 100644 --- a/addons/account/report/account_journal.py +++ b/addons/account/report/account_journal.py @@ -120,7 +120,6 @@ class journal_print(report_sxw.rml_parse, common_report_header): self.cr.execute('SELECT l.id FROM account_move_line l, account_move am WHERE l.move_id=am.id AND am.state IN %s AND l.period_id=%s AND l.journal_id IN %s ' + self.query_get_clause + ' ORDER BY l.'+ self.sort_selection + '',(tuple(move_state), period_id, tuple(journal_id) )) ids = map(lambda x: x[0], self.cr.fetchall()) - print"--ids--",ids return obj_mline.browse(self.cr, self.uid, ids) def _set_get_account_currency_code(self, account_id): From ad3729afff7c24e1c3283f29c84134352759ad76 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Fri, 19 Nov 2010 15:35:20 +0530 Subject: [PATCH 05/30] [ADD] account_sequence:Add internal number in move line and rename the field bzr revid: ara@tinyerp.com-20101119100520-y4w0qdi9anu308wx --- addons/account_sequence/__openerp__.py | 2 +- addons/account_sequence/account_sequence.py | 10 +++- addons/account_sequence/account_sequence.xml | 54 ++++++++++++++++++- .../account_sequence_data.xml | 48 +++++++++++++++-- 4 files changed, 108 insertions(+), 6 deletions(-) diff --git a/addons/account_sequence/__openerp__.py b/addons/account_sequence/__openerp__.py index e6580c4088c..09b5def282f 100644 --- a/addons/account_sequence/__openerp__.py +++ b/addons/account_sequence/__openerp__.py @@ -30,7 +30,7 @@ 'website': 'http://www.openerp.com', 'depends': ['account'], 'init_xml': [], - 'update_xml': ['account_sequence_data.xml','account_sequence.xml'], + 'update_xml': ['account_sequence_data.xml','account_sequence.xml',], 'demo_xml': ['account_sequence_minimal.xml'], 'installable': True, 'active': False, diff --git a/addons/account_sequence/account_sequence.py b/addons/account_sequence/account_sequence.py index 496fb08bc05..a020590d2a6 100644 --- a/addons/account_sequence/account_sequence.py +++ b/addons/account_sequence/account_sequence.py @@ -26,7 +26,7 @@ class account_move(osv.osv): _inherit = 'account.move' _columns = { - 'internal_sequence_number': fields.char('Internal Sequence Number', size=64, readonly=True), + 'internal_sequence_number': fields.char('Internal Number', size=64, readonly=True), } def post(self, cr, uid, ids, context=None): @@ -50,4 +50,12 @@ class account_journal(osv.osv): } account_journal() +class account_move_line(osv.osv): + _inherit = "account.move.line" + + _columns = { + 'internal_sequence_number': fields.related('move_id','internal_sequence_number', type='char', relation='account.move', string='Internal Number'), + } +account_move_line() + # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file diff --git a/addons/account_sequence/account_sequence.xml b/addons/account_sequence/account_sequence.xml index 92c145a9b2e..f434d336875 100644 --- a/addons/account_sequence/account_sequence.xml +++ b/addons/account_sequence/account_sequence.xml @@ -13,7 +13,32 @@ - + + + account.move.tree.inherit + account.move + tree + + + + + + + + + + view.move.search.inherit + account.move + + + + + + + + + + account.journal.form.inherit account.journal @@ -26,5 +51,32 @@ + + + view.move.line.form.inherit + account.move.line + + + + + + + + + + + + view.move.line.search.inherit + account.move.line + + + + + + + + + + diff --git a/addons/account_sequence/account_sequence_data.xml b/addons/account_sequence/account_sequence_data.xml index f5d1117f51d..db2c8e4d0ed 100644 --- a/addons/account_sequence/account_sequence_data.xml +++ b/addons/account_sequence/account_sequence_data.xml @@ -2,14 +2,56 @@ - + Internal Sequence Journal account.journal 1 - + - + + + + + + Internal Number + internal_sequence_number + + + + + + + Internal Number + internal_sequence_number + + + + + + + Internal Number + internal_sequence_number + + + + + + + Internal Number + internal_sequence_number + + + + + + + Internal Number + internal_sequence_number + + + + \ No newline at end of file From fec4573c6b0caf97311cfa0939e238fd44b45b35 Mon Sep 17 00:00:00 2001 From: "ARA (OpenERP)" Date: Fri, 19 Nov 2010 17:01:32 +0530 Subject: [PATCH 06/30] [REF] account_sequence:fix the indentation bzr revid: ara@tinyerp.com-20101119113132-spayua3uly2tzpt5 --- addons/account_sequence/account_sequence.xml | 139 +++++++++--------- .../account_sequence_data.xml | 42 +++--- 2 files changed, 90 insertions(+), 91 deletions(-) diff --git a/addons/account_sequence/account_sequence.xml b/addons/account_sequence/account_sequence.xml index f434d336875..ad8ea7a7e38 100644 --- a/addons/account_sequence/account_sequence.xml +++ b/addons/account_sequence/account_sequence.xml @@ -2,81 +2,80 @@ - - account.move.form.inherit - account.move - form - - - - - - + + account.move.form.inherit + account.move + form + + + + + + - - account.move.tree.inherit - account.move - tree - - - - - - - + + account.move.tree.inherit + account.move + tree + + + + + + + - - view.move.search.inherit - account.move - - - - - - - - - + + view.move.search.inherit + account.move + + + + + + + + + - - account.journal.form.inherit - account.journal - form - - - - - - - + + account.journal.form.inherit + account.journal + form + + + + + + + + + view.move.line.form.inherit + account.move.line + + + + + + + + + - - view.move.line.form.inherit - account.move.line - - - - - - - - - + + view.move.line.search.inherit + account.move.line + + + + + + + + + - - view.move.line.search.inherit - account.move.line - - - - - - - - - - - + diff --git a/addons/account_sequence/account_sequence_data.xml b/addons/account_sequence/account_sequence_data.xml index db2c8e4d0ed..8ce28befcb4 100644 --- a/addons/account_sequence/account_sequence_data.xml +++ b/addons/account_sequence/account_sequence_data.xml @@ -3,8 +3,8 @@ - - Internal Sequence Journal + + Internal Sequence Journal account.journal 1 @@ -13,26 +13,26 @@ - - - Internal Number - internal_sequence_number - - - + + + Internal Number + internal_sequence_number + + + - - - Internal Number - internal_sequence_number - - - + + + Internal Number + internal_sequence_number + + + - - - Internal Number - internal_sequence_number + + + Internal Number + internal_sequence_number @@ -54,4 +54,4 @@ - \ No newline at end of file + From 3d0f4796aef04b2e5a72f6a43f52d8e88527f8a3 Mon Sep 17 00:00:00 2001 From: "qdp-launchpad@tinyerp.com" <> Date: Fri, 19 Nov 2010 12:50:09 +0100 Subject: [PATCH 07/30] [IMP] account_sequence: code cleaning bzr revid: qdp-launchpad@tinyerp.com-20101119115009-bequb9r3dmrnj6z3 --- addons/account_sequence/account_sequence.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/addons/account_sequence/account_sequence.py b/addons/account_sequence/account_sequence.py index c61720f857b..91696edc15d 100644 --- a/addons/account_sequence/account_sequence.py +++ b/addons/account_sequence/account_sequence.py @@ -34,7 +34,6 @@ class account_move(osv.osv): res = super(account_move, self).post(cr, uid, ids, context=context) seq_no = False for line in self.browse(cr, uid, ids): - # Todo: if there is not internal seq defined on journal raise error ? if line.journal_id.internal_sequence: seq_no = obj_sequence.get_id(cr, uid, line.journal_id.internal_sequence.id, context=context) if seq_no: @@ -52,4 +51,4 @@ class account_journal(osv.osv): account_journal() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: From a8f9123fb60d851496c0a1ed1fbf45e909b2a645 Mon Sep 17 00:00:00 2001 From: Mustufa Rangwala Date: Fri, 19 Nov 2010 17:33:31 +0530 Subject: [PATCH 08/30] [MERGE] merge from trunk addons remove regression for account voucher bzr revid: mra@mra-laptop-20101119120331-zbqwg2k4yc8ul979 --- addons/account_voucher/__openerp__.py | 1 - addons/account_voucher/account_voucher.py | 137 +----------------- .../voucher_payment_receipt_view.xml | 4 +- addons/account_voucher/wizard/__init__.py | 1 - .../wizard/account_voucher_payment_option.py | 116 --------------- .../wizard/account_voucher_payment_option.xml | 46 ------ 6 files changed, 3 insertions(+), 302 deletions(-) delete mode 100644 addons/account_voucher/wizard/account_voucher_payment_option.py delete mode 100644 addons/account_voucher/wizard/account_voucher_payment_option.xml diff --git a/addons/account_voucher/__openerp__.py b/addons/account_voucher/__openerp__.py index ca4c0912514..74e3c7383bb 100644 --- a/addons/account_voucher/__openerp__.py +++ b/addons/account_voucher/__openerp__.py @@ -43,7 +43,6 @@ "account_voucher_report.xml", "wizard/account_voucher_unreconcile_view.xml", "wizard/account_statement_from_invoice_view.xml", - "wizard/account_voucher_payment_option.xml", "account_voucher_view.xml", "voucher_payment_receipt_view.xml", "voucher_sales_purchase_view.xml", diff --git a/addons/account_voucher/account_voucher.py b/addons/account_voucher/account_voucher.py index 14abad25413..04bc03c0a36 100644 --- a/addons/account_voucher/account_voucher.py +++ b/addons/account_voucher/account_voucher.py @@ -539,37 +539,6 @@ class account_voucher(osv.osv): self.write(cr, uid, ids, res) return True - def do_check(self, cr, uid, ids, context=None): - mod_obj = self.pool.get('ir.model.data') - if context is None: - context = {} - voucher = self.browse(cr, uid, [ids[0]], context=context)[0] - debit= credit = 0.0 - if voucher.line_dr_ids: - for line in voucher.line_dr_ids: - debit += line.amount_original - if voucher.line_cr_ids: - for line in voucher.line_cr_ids: - credit += line.amount_original - if (voucher.amount + debit) != credit: - model_data_ids = mod_obj.search(cr, uid,[('model', '=', 'ir.ui.view'), ('name', '=', 'view_account_voucher_pay_writeoff')], context=context) - resource_id = mod_obj.read(cr, uid, model_data_ids, fields=['res_id'], context=context)[0]['res_id'] - context.update({'voucher_id': ids[0]}) - return { - 'name': _('Information addendum'), - 'context': context, - 'view_type': 'form', - 'view_mode': 'tree,form', - 'res_model': 'account.voucher.pay.writeoff', - 'views': [(resource_id, 'form')], - 'type': 'ir.actions.act_window', - 'target': 'new', - 'nodestroy': True - } - else: - self.action_move_line_create(cr, uid, ids, context=context) - return True - def unlink(self, cr, uid, ids, context=None): for t in self.read(cr, uid, ids, ['state'], context=context): if t['state'] not in ('draft', 'cancel'): @@ -756,110 +725,6 @@ class account_voucher(osv.osv): move_line_pool.reconcile_partial(cr, uid, rec_ids) return True - def pay_and_reconcile(self, cr, uid, ids, pay_amount, pay_account_id, period_id, pay_journal_id, writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context=None, name=''): - if context is None: - context = {} - seq_obj = self.pool.get('ir.sequence') - #TODO check if we can use different period for payment and the writeoff line - assert len(ids)==1, "Can only pay one voucher at a time" - voucher = self.browse(cr, uid, ids[0]) - if voucher.number: - name = voucher.number - elif voucher.journal_id.sequence_id: - name = seq_obj.get_id(cr, uid, voucher.journal_id.sequence_id.id) - else: - raise osv.except_osv(_('Error !'), _('Please define a sequence on the journal !')) - if not voucher.reference: - ref = name.replace('/','') - else: - ref = voucher.reference - - src_account_id = voucher.account_id.id - # Take the seq as name for move - types = {'sale': -1, 'purchase': 1, 'payment': 1, 'receipt': -1} - direction = types[voucher.type] - #take the choosen date - if 'date_p' in context and context['date_p']: - date = context['date_p'] - else: - date = time.strftime('%Y-%m-%d') - # Take the amount in currency and the currency of the payment - if 'amount_currency' in context and context['amount_currency'] and 'currency_id' in context and context['currency_id']: - amount_currency = context['amount_currency'] - currency_id = context['currency_id'] - else: - amount_currency = False - currency_id = False - pay_journal = self.pool.get('account.journal').read(cr, uid, pay_journal_id, ['type'], context=context) - if voucher.type in ('sale', 'receipt'): - if pay_journal['type'] == 'bank': - entry_type = 'bank_pay_voucher' # Bank payment - else: - entry_type = 'pay_voucher' # Cash payment - else: - entry_type = 'cont_voucher' - - # Pay attention to the sign for both debit/credit AND amount_currency - l1 = { - 'debit': direction * pay_amount>0 and direction * pay_amount, - 'credit': direction * pay_amount<0 and - direction * pay_amount, - 'account_id': src_account_id, - 'partner_id': voucher.partner_id.id, - 'ref':ref, - 'date': date, - 'currency_id':currency_id, - 'amount_currency':amount_currency and direction * amount_currency or 0.0, - 'company_id': voucher.company_id.id, - } - l2 = { - 'debit': direction * pay_amount<0 and - direction * pay_amount, - 'credit': direction * pay_amount>0 and direction * pay_amount, - 'account_id': pay_account_id, - 'partner_id': voucher.partner_id.id, - 'ref':ref, - 'date': date, - 'currency_id':currency_id, - 'amount_currency':amount_currency and - direction * amount_currency or 0.0, - 'company_id': voucher.company_id.id, - } - - if not name: - name = voucher.line_ids and voucher.line_ids[0].name or voucher.number - l1['name'] = name - l2['name'] = name - lines = [(0, 0, l1), (0, 0, l2)] - move = {'ref': ref, 'line_id': lines, 'journal_id': pay_journal_id, 'period_id': period_id, 'name': name, 'date': date} - move_id = self.pool.get('account.move').create(cr, uid, move, context=context) - - line_ids = [] - total = 0.0 - line = self.pool.get('account.move.line') - move_ids = [move_id,] - if voucher.move_id: - move_ids.append(voucher.move_id.id) - cr.execute('SELECT id FROM account_move_line '\ - 'WHERE move_id IN %s', - ((move_id,),)) - lines = line.browse(cr, uid, map(lambda x: x[0], cr.fetchall()) ) - for l in lines: - if l.account_id.id == src_account_id: - line_ids.append(l.id) - total += (l.debit or 0.0) - (l.credit or 0.0) - - voc_id, name = self.name_get(cr, uid, [voucher.id], context=context)[0] - if (not round(total,self.pool.get('decimal.precision').precision_get(cr, uid, 'Account'))) or writeoff_acc_id: - self.pool.get('account.move.line').reconcile(cr, uid, line_ids, 'manual', writeoff_acc_id, writeoff_period_id, writeoff_journal_id, context) - else: - code = voucher.currency_id.code - # TODO: use currency's formatting function - msg = _("Invoice '%s' is paid partially: %s%s of %s%s (%s%s remaining)") % \ - (name, pay_amount, code, voucher.amount_total, code, total, code) - self.log(cr, uid, voc_id, msg) - self.pool.get('account.move.line').reconcile_partial(cr, uid, line_ids, 'manual', context) - # Update the stored value (fields.function), so we write to trigger recompute - self.write(cr, uid, ids, {'state':'posted'}, context=context) - return True - def copy(self, cr, uid, id, default={}, context=None): default.update({ 'state': 'draft', @@ -1063,4 +928,4 @@ class account_bank_statement_line(osv.osv): account_bank_statement_line() -# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: \ No newline at end of file +# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: diff --git a/addons/account_voucher/voucher_payment_receipt_view.xml b/addons/account_voucher/voucher_payment_receipt_view.xml index 1fdb54f1edc..83b6243a627 100644 --- a/addons/account_voucher/voucher_payment_receipt_view.xml +++ b/addons/account_voucher/voucher_payment_receipt_view.xml @@ -217,7 +217,7 @@