openerp-community-reviewer team mailing list archive
-
openerp-community-reviewer team
-
Mailing list archive
-
Message #00916
[Merge] lp:~camptocamp/sale-wkfl/add-partner-prepayment-jge into lp:sale-wkfl
Joël Grand-Guillaume @ camptocamp has proposed merging lp:~camptocamp/sale-wkfl/add-partner-prepayment-jge into lp:sale-wkfl.
Commit message:
[ADD] module partner_prepayment that add a checkbox 'Use prepayment' on customers. When it is activated, the invoicing policy on Sales Orders is set to 'Before Delivery'.
Requested reviews:
Sale Core Editors (sale-core-editors)
For more details, see:
https://code.launchpad.net/~camptocamp/sale-wkfl/add-partner-prepayment-jge/+merge/193603
Hi,
This proposal add the little module partner_prepayment that add a checkbox 'Use prepayment' on customers.
When it is activated, the invoicing policy on Sales Orders is set to 'Before Delivery'.
Regards,
--
https://code.launchpad.net/~camptocamp/sale-wkfl/add-partner-prepayment-jge/+merge/193603
Your team Sale Core Editors is requested to review the proposed merge of lp:~camptocamp/sale-wkfl/add-partner-prepayment-jge into lp:sale-wkfl.
=== added directory 'partner_prepayment'
=== added file 'partner_prepayment/__init__.py'
--- partner_prepayment/__init__.py 1970-01-01 00:00:00 +0000
+++ partner_prepayment/__init__.py 2013-11-01 13:43:02 +0000
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Guewen Baconnier
+# Copyright 2013 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/>.
+#
+##############################################################################
+
+import model
=== added file 'partner_prepayment/__openerp__.py'
--- partner_prepayment/__openerp__.py 1970-01-01 00:00:00 +0000
+++ partner_prepayment/__openerp__.py 2013-11-01 13:43:02 +0000
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright 2013 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': 'Partner Prepayment',
+ 'version': '1.0',
+ 'author': 'Camptocamp',
+ 'category': 'Sales',
+ 'license': 'AGPL-3',
+ 'complexity': 'easy',
+ 'images': [],
+ 'description': """
+Partner Prepayment
+==================
+
+Add a checkbox 'Use prepayment' on customers.
+When it is activated, the invoicing policy on Sales Orders
+is set to 'Before Delivery'.
+
+""",
+ 'depends': ['sale_stock',
+ ],
+ 'demo': [],
+ 'data': ['view/partner_view.xml',
+ ],
+ 'auto_install': False,
+ 'test': ['test/sale_order_prepaid.yml',
+ ],
+ 'installable': True,
+ }
=== added directory 'partner_prepayment/model'
=== added file 'partner_prepayment/model/__init__.py'
--- partner_prepayment/model/__init__.py 1970-01-01 00:00:00 +0000
+++ partner_prepayment/model/__init__.py 2013-11-01 13:43:02 +0000
@@ -0,0 +1,23 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Guewen Baconnier
+# Copyright 2013 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/>.
+#
+##############################################################################
+
+import res_partner
+import sale
=== added file 'partner_prepayment/model/res_partner.py'
--- partner_prepayment/model/res_partner.py 1970-01-01 00:00:00 +0000
+++ partner_prepayment/model/res_partner.py 2013-11-01 13:43:02 +0000
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Guewen Baconnier
+# Copyright 2013 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
+
+
+class res_partner(orm.Model):
+ _inherit = 'res.partner'
+
+ _columns = {
+ 'use_prepayment': fields.boolean(
+ 'Use prepayment',
+ help="When prepayment is activated, the sales order policy "
+ "will be automatically defined to pay before delivery."),
+ }
+
+ def _commercial_fields(self, cr, uid, context=None):
+ fields = super(res_partner, self)._commercial_fields(cr, uid, context=context)
+ fields.append('use_prepayment')
+ return fields
=== added file 'partner_prepayment/model/sale.py'
--- partner_prepayment/model/sale.py 1970-01-01 00:00:00 +0000
+++ partner_prepayment/model/sale.py 2013-11-01 13:43:02 +0000
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Author: Guewen Baconnier
+# Copyright 2013 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
+
+
+class sale_order(orm.Model):
+ _inherit = 'sale.order'
+
+ def onchange_partner_id(self, cr, uid, ids, part, context=None):
+ vals = super(sale_order, self).onchange_partner_id(
+ cr, uid, ids, part, context=context)
+ if not part:
+ return vals
+ partner_obj = self.pool.get('res.partner')
+ partner = partner_obj.browse(cr, uid, part, context=context)
+ if partner.use_prepayment:
+ vals['value']['order_policy'] = 'prepaid'
+ return vals
=== added directory 'partner_prepayment/test'
=== added file 'partner_prepayment/test/sale_order_prepaid.yml'
--- partner_prepayment/test/sale_order_prepaid.yml 1970-01-01 00:00:00 +0000
+++ partner_prepayment/test/sale_order_prepaid.yml 2013-11-01 13:43:02 +0000
@@ -0,0 +1,50 @@
+-
+ Given I activate the 'Use prepayment' on a customer
+-
+ !record {model: res.partner, id: base.res_partner_4}:
+ use_prepayment: True
+-
+ When I create a sale order for a customer not having 'Use prepayment'
+-
+ !record {model: sale.order, id: partner_prepay_sale_01, view: sale_stock.view_order_form_inherit}:
+ partner_id: base.res_partner_3
+ order_policy: 'manual'
+ order_line:
+ - product_id: product.product_product_7
+ product_uom_qty: 8
+-
+ Then the sale order should have the selected policy
+-
+ !assert {model: sale.order, id: partner_prepay_sale_01, string: The order policy should be 'manual'}:
+ - order_policy == 'manual'
+-
+ When I change the sale order for a customer having 'Use prepayment'
+-
+ !record {model: sale.order, id: partner_prepay_sale_01, view: sale_stock.view_order_form_inherit}:
+ partner_id: base.res_partner_4
+-
+ Then the sale order should have the order policy 'prepaid'
+-
+ !assert {model: sale.order, id: partner_prepay_sale_01, string: The order policy should be 'prepaid'}:
+ - order_policy == 'prepaid'
+-
+ When I set the order policy to 'manual' again.
+-
+ !record {model: sale.order, id: partner_prepay_sale_01, view: sale_stock.view_order_form_inherit}:
+ order_policy: manual
+-
+ Then the order policy should be manual
+-
+ !assert {model: sale.order, id: partner_prepay_sale_01, string: The order policy should be 'manual'}:
+ - order_policy == 'manual'
+-
+ And I change the customer of the sale order to a contact of the
+ commercial entity having 'Use prepayment'.
+-
+ !record {model: sale.order, id: partner_prepay_sale_01, view: sale_stock.view_order_form_inherit}:
+ partner_id: base.res_partner_address_8
+-
+ Then the sale order should have the order policy 'prepaid' again.
+-
+ !assert {model: sale.order, id: partner_prepay_sale_01, string: The order policy should be 'prepaid'}:
+ - order_policy == 'prepaid'
=== added directory 'partner_prepayment/view'
=== added file 'partner_prepayment/view/partner_view.xml'
--- partner_prepayment/view/partner_view.xml 1970-01-01 00:00:00 +0000
+++ partner_prepayment/view/partner_view.xml 2013-11-01 13:43:02 +0000
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+ <data noupdate="0">
+ <record id="view_partner_form" model="ir.ui.view">
+ <field name="name">res.partner.form</field>
+ <field name="model">res.partner</field>
+ <field name="inherit_id" ref="base.view_partner_form"/>
+ <field name="arch" type="xml">
+ <field name="user_id" position="after">
+ <field name="use_prepayment"
+ attrs="{'invisible': ['|', ('customer', '!=', True), ('is_company', '=', False), ('parent_id', '!=', False)]}"/>
+ </field>
+ </field>
+ </record>
+ </data>
+</openerp>
Follow ups