[FIX] account_voucher; when making a payment directly from an invoice, copy the invoi...
authorQuentin (OpenERP) <qdp-launchpad@openerp.com>
Fri, 21 Dec 2012 09:58:44 +0000 (10:58 +0100)
committerQuentin (OpenERP) <qdp-launchpad@openerp.com>
Fri, 21 Dec 2012 09:58:44 +0000 (10:58 +0100)
bzr revid: qdp-launchpad@openerp.com-20121221095844-5029t8z6twv67dsc

addons/account_voucher/account_voucher.py
addons/account_voucher/invoice.py
addons/account_voucher/voucher_payment_receipt_view.xml

index 82b18f4..4d51085 100644 (file)
@@ -193,7 +193,9 @@ class account_voucher(osv.osv):
         if context.get('type', 'sale') in ('purchase', 'payment'):
             nodes = doc.xpath("//field[@name='partner_id']")
             for node in nodes:
-                node.set('domain', "[('supplier', '=', True)]")
+                node.set('context', "{'search_default_supplier': 1}")
+                if context.get('invoice_type','') in ('in_invoice', 'in_refund'):
+                    node.set('string', _("Supplier"))
         res['arch'] = etree.tostring(doc)
         return res
 
index 13c4b9a..bd43694 100644 (file)
@@ -27,12 +27,13 @@ class invoice(osv.osv):
 
     def invoice_pay_customer(self, cr, uid, ids, context=None):
         if not ids: return []
-        mod,modid = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_dialog_form')
+        dummy, view_id = self.pool.get('ir.model.data').get_object_reference(cr, uid, 'account_voucher', 'view_vendor_receipt_dialog_form')
+
         inv = self.browse(cr, uid, ids[0], context=context)
         return {
             'name':_("Pay Invoice"),
             'view_mode': 'form',
-            'view_id': modid,
+            'view_id': view_id,
             'view_type': 'form',
             'res_model': 'account.voucher',
             'type': 'ir.actions.act_window',
@@ -42,7 +43,7 @@ class invoice(osv.osv):
             'context': {
                 'default_partner_id': self._find_partner(inv).id,
                 'default_amount': inv.type in ('out_refund', 'in_refund') and -inv.residual or inv.residual,
-                'default_number':inv.name,
+                'default_reference': inv.name,
                 'close_after_process': True,
                 'invoice_type': inv.type,
                 'invoice_id': inv.id,
index b6f3676..e4da7b6 100644 (file)
                     <group>
                         <group>
                             <field name="state" invisible="1"/>
-                            <field name="partner_id" required="1" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date, context)" string="Supplier" context="{'search_default_supplier': 1}"/>
+                            <field name="partner_id" required="1" on_change="onchange_partner_id(partner_id, journal_id, amount, currency_id, type, date, context)" string="Customer" context="{'search_default_customer': 1}"/>
                             <field name="currency_id" invisible="1"/>
                             <field name="amount" class="oe_inline"
                                 string="Paid Amount"