← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~camptocamp/sale-wkfl/7.0-add-sale-default-discount-lep into lp:sale-wkfl

 

Leonardo Pistone - camptocamp has proposed merging lp:~camptocamp/sale-wkfl/7.0-add-sale-default-discount-lep into lp:sale-wkfl.

Requested reviews:
  Sale Core Editors (sale-core-editors)

For more details, see:
https://code.launchpad.net/~camptocamp/sale-wkfl/7.0-add-sale-default-discount-lep/+merge/227214
-- 
https://code.launchpad.net/~camptocamp/sale-wkfl/7.0-add-sale-default-discount-lep/+merge/227214
Your team Sale Core Editors is requested to review the proposed merge of lp:~camptocamp/sale-wkfl/7.0-add-sale-default-discount-lep into lp:sale-wkfl.
=== added directory 'sale_default_discount'
=== added file 'sale_default_discount/__init__.py'
--- sale_default_discount/__init__.py	1970-01-01 00:00:00 +0000
+++ sale_default_discount/__init__.py	2014-07-17 16:01:23 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Author: Leonardo Pistone
+#    Copyright 2014 Camptocamp SA
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from . import model  # noqa

=== added file 'sale_default_discount/__openerp__.py'
--- sale_default_discount/__openerp__.py	1970-01-01 00:00:00 +0000
+++ sale_default_discount/__openerp__.py	2014-07-17 16:01:23 +0000
@@ -0,0 +1,54 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Author: Leonardo Pistone
+#    Copyright 2014 Camptocamp SA
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{
+    'name': 'Sale Default Discount',
+    'version': '1.0',
+    'category': 'Generic Modules/Sale',
+    'description': """
+Sale Default Discount
+=====================
+
+This module allows to set a default discount per customer and per sale order.
+
+The customer discount is used by default when creating an order, and the
+order default is used when creating new order lines.
+
+The defaults can be left empty, keeping the default behaviour.
+
+Contributors
+------------
+
+  * Leonardo Pistone <leonardo.pistone@xxxxxxxxxxxxxx>
+
+""",
+    'author': 'Camptocamp',
+    'depends': ['sale'],
+    'website': 'http://www.camptocamp.com',
+    'data': [
+        'view/partner.xml',
+        'view/sale.xml',
+    ],
+    'test': [
+    ],
+    'demo': [],
+    'installable': True,
+    'active': False,
+}

=== added directory 'sale_default_discount/model'
=== added file 'sale_default_discount/model/__init__.py'
--- sale_default_discount/model/__init__.py	1970-01-01 00:00:00 +0000
+++ sale_default_discount/model/__init__.py	2014-07-17 16:01:23 +0000
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Author: Leonardo Pistone
+#    Copyright 2014 Camptocamp SA
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from . import partner  # noqa
+from . import sale  # noqa

=== added file 'sale_default_discount/model/partner.py'
--- sale_default_discount/model/partner.py	1970-01-01 00:00:00 +0000
+++ sale_default_discount/model/partner.py	2014-07-17 16:01:23 +0000
@@ -0,0 +1,34 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Author: Leonardo Pistone
+#    Copyright 2014 Camptocamp SA
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+import openerp.addons.decimal_precision as dp
+
+
+class Partner(orm.Model):
+    _inherit = 'res.partner'
+
+    _columns = {
+        'discount': fields.float(
+            'Default discount (%)',
+            digits_compute=dp.get_precision('discount'),
+        ),
+    }

=== added file 'sale_default_discount/model/sale.py'
--- sale_default_discount/model/sale.py	1970-01-01 00:00:00 +0000
+++ sale_default_discount/model/sale.py	2014-07-17 16:01:23 +0000
@@ -0,0 +1,47 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Author: Leonardo Pistone
+#    Copyright 2014 Camptocamp SA
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+from openerp.osv import orm, fields
+import openerp.addons.decimal_precision as dp
+
+
+class SaleOrder(orm.Model):
+    _inherit = 'sale.order'
+
+    _columns = {
+        'discount': fields.float(
+            'Default discount (%)',
+            digits_compute=dp.get_precision('discount'),
+            help='This discount is used by default when creating new lines',
+        ),
+    }
+
+    def onchange_partner_id(self, cr, uid, ids, partner_id, context=None):
+        result = super(SaleOrder, self).onchange_partner_id(
+            cr, uid, ids, partner_id, context=context)
+
+        if partner_id:
+            partner = self.pool['res.partner'].browse(
+                cr, uid, partner_id, context=context)
+            if partner.discount:
+                result['value']['discount'] = partner.discount
+
+        return result

=== added directory 'sale_default_discount/view'
=== added file 'sale_default_discount/view/partner.xml'
--- sale_default_discount/view/partner.xml	1970-01-01 00:00:00 +0000
+++ sale_default_discount/view/partner.xml	2014-07-17 16:01:23 +0000
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+  <data>
+
+    <record id="view_partner_form" model="ir.ui.view">
+      <field name="name">view.partner.form</field>
+      <field name="model">res.partner</field>
+      <field name="inherit_id" ref="base.view_partner_form"/>
+      <field 
+        name="groups_id"
+        eval="[(6, 0, [ref('sale.group_discount_per_so_line')])]"/>
+      <field name="arch" type="xml">
+        <field name="user_id" position="after">
+          <field name="discount"/>
+        </field>
+      </field>
+    </record>
+
+  </data>
+</openerp>

=== added file 'sale_default_discount/view/sale.xml'
--- sale_default_discount/view/sale.xml	1970-01-01 00:00:00 +0000
+++ sale_default_discount/view/sale.xml	2014-07-17 16:01:23 +0000
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+  <data>
+
+    <record id="view_order_form" model="ir.ui.view">
+      <field name="name">sale.order.form</field>
+      <field name="model">sale.order</field>
+      <field name="inherit_id" ref="sale.view_order_form"/>
+      <field 
+        name="groups_id"
+        eval="[(6, 0, [ref('sale.group_discount_per_so_line')])]"/>
+      <field name="arch" type="xml">
+
+        <group name="sales_person" position="after">
+          <group>
+            <field 
+              name="discount" 
+              groups="sale.group_discount_per_so_line"/>
+          </group>
+        </group>
+
+        <field name="order_line" position="attributes">
+          <!-- that means: the default for the field "discount" on the line
+               comes from the field "discount" on the order -->
+          <attribute name="context">
+            {'default_discount': discount}
+          </attribute>
+        </field>
+
+      </field>
+    </record>
+
+  </data>
+</openerp>


Follow ups