Saurang Suthar(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-advance_invoice-ssu into
lp:openobject-addons.
Requested reviews:
OpenERP Core Team (openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-advance_invoice-ssu/+merge/100604
Hello,
Improved Advance Invoice.
Optimized more wizard steps.
Now amount can be set as percentage or fixed rate by selection.
Improved the product selection filter.
Set value of product named Advance as default value.
Thank you.
Saurang - ssu
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-advance_invoice-ssu/+merge/100604
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-advance_invoice-ssu.
=== modified file 'product/product_view.xml'
--- product/product_view.xml 2012-03-20 09:39:43 +0000
+++ product/product_view.xml 2012-04-03 13:40:30 +0000
@@ -9,7 +9,7 @@
<field name="type">search</field>
<field name="arch" type="xml">
<search string="Product">
- <filter string="Services" icon="terp-accessories-archiver" domain="[('type','=','service')]"/>
+ <filter string="Services" name="services" icon="terp-accessories-archiver" domain="[('type','=','service')]"/>
<filter string="Products" icon="terp-accessories-archiver" domain="['|',('type','=','product'),('type','=','consu')]" help="Both stockable and consumable products"/>
<separator orientation="vertical"/>
<filter string="To Sell" name="filter_to_sell" icon="terp-accessories-archiver-minus" domain="[('sale_ok','=',1)]"/>
=== modified file 'sale/sale_data.xml'
--- sale/sale_data.xml 2011-10-16 01:28:00 +0000
+++ sale/sale_data.xml 2012-04-03 13:40:30 +0000
@@ -26,5 +26,16 @@
<function eval="('default',False,'shop_id', [('sale.order', False)], shop, True, False, False, False, True)" id="sale_default_set" model="ir.values" name="set"/>
+ <record id="advance_product_0" model="product.product">
+ <field name="name">Advance</field>
+ <field name="categ_id" ref="product.cat1"/>
+ <field name="type">service</field>
+ <field name="list_price">150.0</field>
+ <field name="standard_price">100.0</field>
+ <field name="supply_method">produce</field>
+ <field name="uom_id" ref="product.uom_day"/>
+ <field name="uom_po_id" ref="product.uom_day"/>
+ </record>
+
</data>
</openerp>
=== modified file 'sale/sale_demo.xml'
--- sale/sale_demo.xml 2012-03-20 05:22:58 +0000
+++ sale/sale_demo.xml 2012-04-03 13:40:30 +0000
@@ -259,16 +259,7 @@
<!-- sale advance demo.. -->
<!-- Demo Data for Product -->
- <record id="advance_product_0" model="product.product">
- <field name="name">Advance</field>
- <field name="categ_id" ref="product.cat1"/>
- <field name="type">service</field>
- <field name="list_price">150.0</field>
- <field name="standard_price">100.0</field>
- <field name="supply_method">produce</field>
- <field name="uom_id" ref="product.uom_day"/>
- <field name="uom_po_id" ref="product.uom_day"/>
- </record>
+
<record id="base.user_demo" model="res.users">
<field eval="[(4, ref('base.group_sale_salesman'))]" name="groups_id"/>
=== modified file 'sale/wizard/sale_make_invoice_advance.py'
--- sale/wizard/sale_make_invoice_advance.py 2012-03-05 13:25:43 +0000
+++ sale/wizard/sale_make_invoice_advance.py 2012-04-03 13:40:30 +0000
@@ -24,16 +24,33 @@
class sale_advance_payment_inv(osv.osv_memory):
_name = "sale.advance.payment.inv"
_description = "Sales Advance Payment Invoice"
+
_columns = {
'product_id': fields.many2one('product.product', 'Advance Product', required=True,
help="Select a product of type service which is called 'Advance Product'. You may have to create it and set it as a default value on this field."),
'amount': fields.float('Advance Amount', digits=(16, 2), required=True, help="The amount to be invoiced in advance."),
'qtty': fields.float('Quantity', digits=(16, 2), required=True),
+ 'pay_type':fields.selection([('percentage','Percentage'), ('fixed','Fixed')], 'Pay Type', required=True),
}
+
_defaults = {
- 'qtty': 1.0
+ 'qtty': 1.0,
+ 'pay_type': 'percentage',
}
+ def default_get(self, cr, uid, fields, context=None):
+ if context is None:
+ context = {}
+ record_id = context and context.get('active_id', False) or False
+ res = super(sale_advance_payment_inv, self).default_get(cr, uid, fields, context=context)
+ data_obj = self.pool.get('ir.model.data')
+ res_id = data_obj._get_id(cr, uid, 'sale', 'advance_product_0')
+ if res_id:
+ product_id = data_obj.browse(cr, uid, res_id, context=context).res_id
+ if product_id:
+ res.update({'product_id':product_id})
+ return res
+
def create_invoices(self, cr, uid, ids, context=None):
"""
To create invoices.
@@ -47,6 +64,7 @@
@return:
"""
+
list_inv = []
obj_sale = self.pool.get('sale.order')
obj_lines = self.pool.get('account.invoice.line')
@@ -72,10 +90,20 @@
'for this product: "%s" (id:%d)') % \
(sale_adv_obj.product_id.name, sale_adv_obj.product_id.id,))
+ final_amount = 0
+ if sale_adv_obj.amount <= 0.00:
+ raise osv.except_osv(_('Data Insufficient !'),
+ _('Please check the Advance Amount, it should not be 0 or less!'))
+ else:
+ if sale_adv_obj.pay_type == 'percentage':
+ final_amount = sale_adv_obj.product_id.list_price * sale_adv_obj.amount / 100
+ else:
+ final_amount = sale_adv_obj.amount
+
line_id = obj_lines.create(cr, uid, {
'name': res.get('name'),
'account_id': res['account_id'],
- 'price_unit': sale_adv_obj.amount,
+ 'price_unit': final_amount,
'quantity': sale_adv_obj.qtty,
'discount': False,
'uos_id': res.get('uos_id'),
@@ -115,7 +143,7 @@
self.pool.get('sale.order.line').create(cr, uid, {
'order_id': sale.id,
'name': res.get('name'),
- 'price_unit': -sale_adv_obj.amount,
+ 'price_unit': -final_amount,
'product_uom_qty': sale_adv_obj.qtty,
'product_uos_qty': sale_adv_obj.qtty,
'product_uos': res.get('uos_id'),
@@ -127,23 +155,13 @@
context.update({'invoice_id':list_inv})
- return {
- 'name': 'Open Invoice',
- 'view_type': 'form',
- 'view_mode': 'form',
- 'res_model': 'sale.open.invoice',
- 'type': 'ir.actions.act_window',
- 'target': 'new',
- 'context': context
- }
-
-sale_advance_payment_inv()
-
-class sale_open_invoice(osv.osv_memory):
- _name = "sale.open.invoice"
- _description = "Sales Open Invoice"
-
- def open_invoice(self, cr, uid, ids, context=None):
+ if context['open_invoices'] == True:
+ return self.open_invoices( cr, uid, ids, context=context)
+
+ else:
+ return {'type': 'ir.actions.act_window_close'}
+
+ def open_invoices(self, cr, uid, ids, context=None):
"""
To open invoice.
@@ -176,6 +194,6 @@
'type': 'ir.actions.act_window',
}
-sale_open_invoice()
+sale_advance_payment_inv()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== modified file 'sale/wizard/sale_make_invoice_advance.xml'
--- sale/wizard/sale_make_invoice_advance.xml 2011-01-14 00:11:01 +0000
+++ sale/wizard/sale_make_invoice_advance.xml 2012-04-03 13:40:30 +0000
@@ -7,15 +7,24 @@
<field name="type">form</field>
<field name="arch" type="xml">
<form string="Advance Invoice">
- <field name="product_id"/>
+ <field name="product_id" context="{'search_default_services':1}" />
<newline />
<field name="qtty" invisible="1"/>
- <field name="amount"/>
+ <group>
+ <label string="Advance Amount :" help="The amount to be invoiced in advance."/>
+ </group>
+ <group>
+ <field name="pay_type" nolabel="1" />
+ </group>
+ <group>
+ <field name="amount" nolabel="1" />
+ </group>
<newline />
<separator string="" colspan="4"/>
- <label string="" colspan="2" />
+ <label string="" colspan="6" />
<button special="cancel" string="Cancel" icon="gtk-cancel"/>
- <button name="create_invoices" string="Create Invoice" type="object" icon="gtk-go-forward"/>
+ <button name="create_invoices" string="Create Invoice" type="object" icon="gtk-go-forward" context="{'open_invoices': False}"/>
+ <button name="create_invoices" string="Create and view Invoice" type="object" icon="terp-camera_test" context="{'open_invoices': True}" />
</form>
</field>
</record>
@@ -28,31 +37,5 @@
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
-
- <record id="view_sale_open_invoice" model="ir.ui.view">
- <field name="name">Open Invoice</field>
- <field name="model">sale.open.invoice</field>
- <field name="type">form</field>
- <field name="arch" type="xml">
- <form string="Invoices">
- <label string="You invoice has been successfully created!" />
- <newline />
- <separator string="" colspan="4"/>
- <group colspan="4">
- <button special="cancel" string="Close" icon="gtk-cancel"/>
- <button name="open_invoice" string="Open Invoice" type="object" icon="gtk-go-forward"/>
- </group>
- </form>
- </field>
- </record>
-
- <record id="action_view_sale_open_invoice" model="ir.actions.act_window">
- <field name="name">Open Invoice</field>
- <field name="type">ir.actions.act_window</field>
- <field name="res_model">sale.open.invoice</field>
- <field name="view_type">form</field>
- <field name="view_mode">form</field>
- <field name="target">new</field>
- </record>
</data>
</openerp>
=== modified file 'stock/stock_demo.xml'
--- stock/stock_demo.xml 2012-03-30 07:49:01 +0000
+++ stock/stock_demo.xml 2012-04-03 13:40:30 +0000
@@ -237,7 +237,11 @@
<field eval=""""Shop 2"""" name="name"/>
</record>
<record id="stock_location_intermediatelocation0" model="stock.location">
+<<<<<<< TREE
<field name="partner_id" ref="base.main_partner"/>
+=======
+ <!--field name="address_id" ref="base.main_address"/-->
+>>>>>>> MERGE-SOURCE
<field name="location_id" ref="stock.stock_location_locations_partner"/>
<field eval=""""procurement"""" name="usage"/>
<field eval=""""Internal Shippings"""" name="name"/>
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp