← Back to team overview

savoirfairelinux-openerp team mailing list archive

lp:~savoirfairelinux-openerp/openerp-canada/7.0-l10n_ca_account_check_writing-supplier-ref into lp:openerp-canada

 

Virgil Dupras has proposed merging lp:~savoirfairelinux-openerp/openerp-canada/7.0-l10n_ca_account_check_writing-supplier-ref into lp:openerp-canada.

Requested reviews:
  OpenERP Community Reviewer (openerp-community-reviewer)

For more details, see:
https://code.launchpad.net/~savoirfairelinux-openerp/openerp-canada/7.0-l10n_ca_account_check_writing-supplier-ref/+merge/165671
-- 
https://code.launchpad.net/~savoirfairelinux-openerp/openerp-canada/7.0-l10n_ca_account_check_writing-supplier-ref/+merge/165671
Your team Savoir-faire Linux' OpenERP is subscribed to branch lp:~savoirfairelinux-openerp/openerp-canada/7.0-l10n_ca_account_check_writing-supplier-ref.
=== modified file 'l10n_ca_account_check_writing/account_voucher.py'
--- l10n_ca_account_check_writing/account_voucher.py	2013-05-10 14:57:50 +0000
+++ l10n_ca_account_check_writing/account_voucher.py	2013-05-24 17:08:30 +0000
@@ -72,3 +72,28 @@
                 },
             'nodestroy': True
             }
+
+# By default, the supplier reference number is not so easily accessible from a voucher line because
+# there's no direct link between the voucher and the invoice. Fortunately, there was this recently
+# submitted patch from Lorenzo Battistini (Agile) BG at
+# https://code.launchpad.net/~elbati/account-payment/adding_account_voucher_supplier_invoice_number_7/+merge/165622
+# which solves this exact problem and I shamelessely copied that code, which works well.
+
+class voucher_line(orm.Model):
+    _inherit = 'account.voucher.line'
+    
+    def get_suppl_inv_num(self, cr, uid, move_line_id, context=None):
+        move_line = self.pool.get('account.move.line').browse(cr, uid, move_line_id, context)
+        return (move_line.invoice and move_line.invoice.supplier_invoice_number or '')
+
+    def _get_supplier_invoice_number(self, cr, uid, ids, name, args, context=None):
+        res={}
+        for line in self.browse(cr, uid, ids, context):
+            res[line.id] = ''
+            if line.move_line_id:
+                res[line.id] = self.get_suppl_inv_num(cr, uid, line.move_line_id.id, context=context)
+        return res
+    
+    _columns = {
+        'supplier_invoice_number': fields.function(_get_supplier_invoice_number, type='char', size=64, string="Supplier Invoice Number"),
+    }

=== modified file 'l10n_ca_account_check_writing/report/l10n_ca_check_print.py'
--- l10n_ca_account_check_writing/report/l10n_ca_check_print.py	2013-05-10 16:02:52 +0000
+++ l10n_ca_account_check_writing/report/l10n_ca_check_print.py	2013-05-24 17:08:30 +0000
@@ -47,12 +47,20 @@
         self.number_lines = len(voucher_lines)
         for i in range(0, min(10,self.number_lines)):
             if i < self.number_lines:
+                voucher_line = voucher_lines[i]
+                # In general, the supplier invoice reference number is a much better description
+                # for writing checks than our own reference number, but if we don't have it, we
+                # might as well use our internal number
+                if voucher_line.supplier_invoice_number:
+                    name = voucher_line.supplier_invoice_number
+                else:
+                    name = voucher_line.name
                 res = {
-                    'date_due' : voucher_lines[i].date_due,
-                    'name' : voucher_lines[i].name,
-                    'amount_original' : voucher_lines[i].amount_original and voucher_lines[i].amount_original or False,
-                    'amount_unreconciled' : voucher_lines[i].amount_unreconciled and voucher_lines[i].amount_unreconciled or False,
-                    'amount' : voucher_lines[i].amount and voucher_lines[i].amount or False,
+                    'date_due' : voucher_line.date_due,
+                    'name' : name,
+                    'amount_original' : voucher_line.amount_original and voucher_line.amount_original or False,
+                    'amount_unreconciled' : voucher_line.amount_unreconciled and voucher_line.amount_unreconciled or False,
+                    'amount' : voucher_line.amount and voucher_line.amount or False,
                 }
             else :
                 res = {