← Back to team overview

openerp-community-reviewer team mailing list archive

[Merge] lp:~camptocamp/contract-management/7.0-add-product-attribute-hours-block-mdh into lp:contract-management

 

Matthieu Dietrich @ camptocamp has proposed merging lp:~camptocamp/contract-management/7.0-add-product-attribute-hours-block-mdh into lp:contract-management.

Commit message:
[IMP] added product attribute to discard invoice lines with this product in hours block

Requested reviews:
  Contract Management Core Editors (contract-management-core-editors)

For more details, see:
https://code.launchpad.net/~camptocamp/contract-management/7.0-add-product-attribute-hours-block-mdh/+merge/204957

All invoice lines are considered in hours block; this adds an attribute to the product, so that any line with a checked product will not be used for computing the bought hours.
-- 
https://code.launchpad.net/~camptocamp/contract-management/7.0-add-product-attribute-hours-block-mdh/+merge/204957
Your team Contract Management Core Editors is requested to review the proposed merge of lp:~camptocamp/contract-management/7.0-add-product-attribute-hours-block-mdh into lp:contract-management.
=== modified file 'analytic_hours_block/__init__.py'
--- analytic_hours_block/__init__.py	2012-12-17 12:31:50 +0000
+++ analytic_hours_block/__init__.py	2014-02-05 14:28:48 +0000
@@ -20,3 +20,4 @@
 ##############################################################################
 import hours_block
 import report
+import product

=== modified file 'analytic_hours_block/__openerp__.py'
--- analytic_hours_block/__openerp__.py	2014-01-08 11:55:30 +0000
+++ analytic_hours_block/__openerp__.py	2014-02-05 14:28:48 +0000
@@ -46,6 +46,7 @@
         "hours_block_view.xml",
         "hours_block_data.xml",
         "hours_block_menu.xml",
+        "product_view.xml",
         "report.xml",
         "security/hours_block_security.xml",
         "security/ir.model.access.csv",

=== modified file 'analytic_hours_block/hours_block.py'
--- analytic_hours_block/hours_block.py	2014-01-31 14:45:54 +0000
+++ analytic_hours_block/hours_block.py	2014-02-05 14:28:48 +0000
@@ -48,7 +48,7 @@
             # Compute hours bought
             for line in block.invoice_id.invoice_line:
                 hours_bought = 0.0
-                if line.product_id:
+                if line.product_id and line.product_id.is_in_hours_block:
                     # We will now calculate the product_quantity
                     factor = line.uos_id.factor
                     if factor == 0.0:

=== added file 'analytic_hours_block/product.py'
--- analytic_hours_block/product.py	1970-01-01 00:00:00 +0000
+++ analytic_hours_block/product.py	2014-02-05 14:28:48 +0000
@@ -0,0 +1,38 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Author: Matthieu Dietrich
+#    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
+
+
+class Product(orm.Model):
+    _name = "product.product"
+    _inherit = 'product.product'
+
+    _columns = {
+        'is_in_hours_block': fields.boolean(
+            'Accounted for hours block?',
+            help="Specify if you want to have invoice lines "
+                 "containing this product to be considered for hours blocks.")
+    }
+
+    _defaults = {
+        'is_in_hours_block': False
+    }

=== added file 'analytic_hours_block/product_view.xml'
--- analytic_hours_block/product_view.xml	1970-01-01 00:00:00 +0000
+++ analytic_hours_block/product_view.xml	2014-02-05 14:28:48 +0000
@@ -0,0 +1,18 @@
+<?xml version="1.0" ?>
+<openerp>
+    <data>
+
+        <record id="view_product_hours_block_form" model="ir.ui.view">
+            <field name="name">product.product.block.form</field>
+            <field name="model">product.product</field>
+            <field name="inherit_id" ref="product.product_normal_form_view"/>
+            <field name="arch" type="xml">
+                <div name="options" position="inside">
+                    <field name="is_in_hours_block"/>
+                    <label for="is_in_hours_block"/>
+                </div>
+            </field>
+        </record>
+
+    </data>
+</openerp>


Follow ups