clearcorp team mailing list archive
-
clearcorp team
-
Mailing list archive
-
Message #00144
lp:~juan-munoz-clearcorp/openerp-ccorp-addons/account_invoice_webkit_report_feature2 into lp:openerp-ccorp-addons/6.1
Juan Felipe Muñoz Ramos has proposed merging lp:~juan-munoz-clearcorp/openerp-ccorp-addons/account_invoice_webkit_report_feature2 into lp:openerp-ccorp-addons/6.1.
Requested reviews:
CLEARCORP development team (clearcorp)
For more details, see:
https://code.launchpad.net/~juan-munoz-clearcorp/openerp-ccorp-addons/account_invoice_webkit_report_feature2/+merge/105718
[FIX] migated wizard of Global Discount to 6.1
--
https://code.launchpad.net/~juan-munoz-clearcorp/openerp-ccorp-addons/account_invoice_webkit_report_feature2/+merge/105718
Your team CLEARCORP development team is requested to review the proposed merge of lp:~juan-munoz-clearcorp/openerp-ccorp-addons/account_invoice_webkit_report_feature2 into lp:openerp-ccorp-addons/6.1.
=== modified file 'account_invoice_global_discount/__openerp__.py'
--- account_invoice_global_discount/__openerp__.py 2012-05-08 04:28:18 +0000
+++ account_invoice_global_discount/__openerp__.py 2012-05-14 20:30:25 +0000
@@ -41,6 +41,7 @@
"init_xml" : [],
"demo_xml" : [],
"update_xml" : [
+ 'wizard/discount_wizard.xml',
'account_invoice_global_discount_wizard.xml',
'account_invoice_global_discount_view.xml',
],
=== modified file 'account_invoice_global_discount/account_invoice_global_discount_wizard.xml'
--- account_invoice_global_discount/account_invoice_global_discount_wizard.xml 2010-08-14 19:57:04 +0000
+++ account_invoice_global_discount/account_invoice_global_discount_wizard.xml 2012-05-14 20:30:25 +0000
@@ -4,6 +4,6 @@
<!--
Resource: account.invoice
-->
- <wizard string="Discount" model="account.invoice" name="invoice.discount" id="invoice_discount" menu="False"/>
+ <!--wizard string="Discount" model="account.invoice" name="invoice.discount" id="invoice_discount" menu="False"/-->
</data>
</openerp>
=== modified file 'account_invoice_global_discount/wizard/discount_wizard.py'
--- account_invoice_global_discount/wizard/discount_wizard.py 2010-08-15 05:26:10 +0000
+++ account_invoice_global_discount/wizard/discount_wizard.py 2012-05-14 20:30:25 +0000
@@ -34,54 +34,33 @@
import pooler
import wizard
-
-
-_form = """<?xml version="1.0"?>
-<form string="Discount:">
- <field name="discount"/>
-</form>
-"""
-
-_fields = {
- 'discount': {
- 'string': 'Discount percentage',
- 'type': 'float',
- 'required': True,
- 'default': lambda *args: 0
- },
-}
-
-
-def apply_discount(self, cr, uid, data, context):
- pool = pooler.get_pool(cr.dbname)
- invoice_obj = pool.get('account.invoice')
- invoice_line_obj = pool.get('account.invoice.line')
- for invoice in invoice_obj.browse(cr, uid, data['ids'], context=context):
- invoice_line_obj.write(cr, uid, [line.id for line in invoice.invoice_line], {'discount': data['form']['discount']}, context=context,)
- return {}
-
-
-class discount_wizard(wizard.interface):
- states = {
- 'init': {
- 'actions': [],
- 'result': {
- 'type': 'form',
- 'arch': _form,
- 'fields': _fields,
- 'state': (('end', 'Cancel'),
- ('apply_discount', 'Apply Discount', 'gtk-ok', True)
- )
- }
- },
- 'apply_discount': {
- 'actions': [],
- 'result': {
- 'type': 'action',
- 'action': apply_discount,
- 'state': "end",
- }
- },
- }
-
-discount_wizard('invoice.discount')
+from osv import fields, osv, orm
+
+
+class discount_wizard(osv.osv_memory):
+ _name = 'discount_wizard'
+
+ _columns = {
+ 'discount': fields.float('Discount percentage', required=True,),
+
+
+ }
+
+ _defaults = {
+ 'discount': lambda *args: 0,
+
+ }
+
+ def apply_discount(self, cr, uid, data, context):
+ pool = pooler.get_pool(cr.dbname)
+ invoice_obj = pool.get('account.invoice')
+ invoice_line_obj = pool.get('account.invoice.line')
+ fields = self.browse(cr,uid,data[0])
+ discount2 = fields['discount']
+ for invoice in invoice_obj.browse(cr, uid, context['active_ids'], context=context):
+ invoice_line_obj.write(cr, uid, [line.id for line in invoice.invoice_line], {'discount': discount2}, context=context,)
+ return {}
+
+
+
+discount_wizard()
=== added file 'account_invoice_global_discount/wizard/discount_wizard.xml'
--- account_invoice_global_discount/wizard/discount_wizard.xml 1970-01-01 00:00:00 +0000
+++ account_invoice_global_discount/wizard/discount_wizard.xml 2012-05-14 20:30:25 +0000
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data noupdate="1">
+ <!--
+ Winpdb debugger start wizard
+ -->
+
+
+
+
+
+ <record model="ir.ui.view" id="discount_wizard_form_view">
+ <field name="name">discount_wizard_form</field>
+ <field name="model">discount_wizard</field>
+ <field name="type">form</field>
+ <field name="arch" type="xml">
+ <form string="Account Global Discount">
+ <label string="The following discount will apply to all lines of the invoice" colspan="4"/>
+ <field name="discount"/>
+ <button type="special" special="cancel"
+ string="Cancel" icon="gtk-cancel"/>
+ <button type="object" name="apply_discount"
+ string="Apply Discount" icon="gtk-ok"/>
+ </form>
+ </field>
+ </record>
+
+
+
+
+
+ <record model="ir.actions.act_window" id="invoice_discount">
+ <field name="name">account_discount_wizard_action</field>
+ <field name="res_model">discount_wizard</field>
+ <field name="view_type">form</field>
+ <field name="view_mode">form</field>
+ <field name="view_id" ref="discount_wizard_form_view"/>
+ <field name="target">new</field>
+ </record>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ </data>
+</openerp>
Follow ups