← Back to team overview

openerp-dev-web team mailing list archive

[Merge] lp:~openerp-dev/openobject-addons/trunk-bug-729602-ara into lp:openobject-addons

 

Ashvin Rathod (OpenERP) has proposed merging lp:~openerp-dev/openobject-addons/trunk-bug-729602-ara into lp:openobject-addons.

Requested reviews:
  Mustufa Rangwala (Open ERP) (mra-tinyerp)
  Ashvin Rathod (OpenERP) (ara-tinyerp)
  OpenERP buildbot (openerp-buildbot)
Related bugs:
  #729602 [6.0] invoice - must check if product is "to_sell", "to_purchase"
  https://bugs.launchpad.net/bugs/729602

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-729602-ara/+merge/52682

Hello,

Fix the bug: [6.0] invoice - must check if product is "to_sell", "to_purchase"
https://bugs.launchpad.net/openobject-addons/+bug/729602

Thanks,
ara
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-bug-729602-ara/+merge/52682
Your team OpenERP R&D Team is subscribed to branch lp:~openerp-dev/openobject-addons/trunk-bug-729602-ara.
=== modified file 'account/account_invoice_view.xml'
--- account/account_invoice_view.xml	2011-01-27 09:49:39 +0000
+++ account/account_invoice_view.xml	2011-03-09 13:56:25 +0000
@@ -172,7 +172,7 @@
                             <field name="reference" nolabel="1"/>
                             <field name="date_due"/>
                             <field name="check_total" required="2"/>
-                            <field colspan="4" default_get="{'check_total': check_total, 'invoice_line': invoice_line, 'address_invoice_id': address_invoice_id, 'partner_id': partner_id, 'price_type': 'price_type' in dir() and price_type or False}" name="invoice_line" nolabel="1">
+                            <field colspan="4" default_get="{'check_total': check_total, 'invoice_line': invoice_line, 'address_invoice_id': address_invoice_id, 'partner_id': partner_id, 'price_type': 'price_type' in dir() and price_type or False}" name="invoice_line" context="{'type': type}" nolabel="1">
                                 <tree string="Invoice lines">
                                     <field name="product_id" on_change="product_id_change(product_id, uos_id, quantity, name, parent.type, parent.partner_id, parent.fiscal_position, price_unit, parent.address_invoice_id, parent.currency_id, {'company_id': parent.company_id})"/>
                                     <field domain="[('company_id', '=', parent.company_id), ('journal_id', '=', parent.journal_id), ('type', '&lt;&gt;', 'view')]" name="account_id" on_change="onchange_account_id(parent.fiscal_position,account_id)"/>
@@ -280,7 +280,7 @@
                             <field domain="[('company_id', '=', company_id),('type','=', 'receivable')]" name="account_id" groups="account.group_account_user"/>
                             <field name="name"/>
                             <field name="payment_term" widget="selection"/>
-                            <field colspan="4" name="invoice_line" nolabel="1" widget="one2many_list"/>
+                            <field colspan="4" name="invoice_line" nolabel="1" widget="one2many_list" context="{'type': type}"/>
                             <group col="1" colspan="2">
                                 <field name="tax_line" nolabel="1">
                                     <tree editable="bottom" string="Taxes">

=== modified file 'account/invoice.py'
--- account/invoice.py	2011-03-03 17:07:00 +0000
+++ account/invoice.py	2011-03-09 13:56:25 +0000
@@ -1290,6 +1290,20 @@
         'price_unit': _price_unit_default,
     }
 
+    def fields_view_get(self, cr, uid, view_id=None, view_type='form', context=None, toolbar=False, submenu=False):
+        if context is None:
+            context = {}
+        res = super(account_invoice_line,self).fields_view_get(cr, uid, view_id=view_id, view_type=view_type, context=context, toolbar=toolbar, submenu=submenu)
+        if context.get('type', False):
+            doc = etree.XML(res['arch'])
+            for node in doc.xpath("//field[@name='product_id']"):
+                if context['type'] in ('in_invoice', 'in_refund'):
+                    node.set('domain', "[('purchase_ok', '=', True)]")
+                else:
+                    node.set('domain', "[('sale_ok', '=', True)]")
+            res['arch'] = etree.tostring(doc)
+        return res
+
     def product_id_change(self, cr, uid, ids, product, uom, qty=0, name='', type='out_invoice', partner_id=False, fposition_id=False, price_unit=False, address_invoice_id=False, currency_id=False, context=None):
         if context is None:
             context = {}

=== modified file 'point_of_sale/wizard/pos_payment.py'
--- point_of_sale/wizard/pos_payment.py	2011-01-24 16:13:46 +0000
+++ point_of_sale/wizard/pos_payment.py	2011-03-09 13:56:25 +0000
@@ -142,6 +142,7 @@
         if the order is paid print invoice (if wanted) or ticket.
         """
         order_obj = self.pool.get('pos.order')
+        obj_partner = self.pool.get('res.partner')
         if context is None:
             context = {}
         active_id = context and context.get('active_id', False)
@@ -156,6 +157,9 @@
             order_obj.add_payment(cr, uid, active_id, data, context=context)
 
         if order_obj.test_paid(cr, uid, [active_id]):
+            partner = obj_partner.browse(cr, uid, data['partner_id'], context=context)
+            if not partner.address:
+                raise osv.except_osv(_('Error!'),_("Partner doesn't have an address to make the invoice."))
             if data['partner_id'] and data['invoice_wanted']:
                 order_obj.action_invoice(cr, uid, [active_id], context=context)
                 order_obj.create_picking(cr, uid, [active_id], context=context)