From 6c80ff82a9e2e44422c92a52a0546676efa1436c Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Wed, 5 Feb 2014 15:24:42 +0100 Subject: [PATCH 1/2] [IMP] added new attribute to product --- analytic_hours_block/__init__.py | 1 + analytic_hours_block/__openerp__.py | 1 + analytic_hours_block/hours_block.py | 2 +- analytic_hours_block/product.py | 38 +++++++++++++++++++++++++++ analytic_hours_block/product_view.xml | 18 +++++++++++++ 5 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 analytic_hours_block/product.py create mode 100644 analytic_hours_block/product_view.xml diff --git a/analytic_hours_block/__init__.py b/analytic_hours_block/__init__.py index 93f4db71..42354634 100644 --- a/analytic_hours_block/__init__.py +++ b/analytic_hours_block/__init__.py @@ -20,3 +20,4 @@ ############################################################################## import hours_block import report +import product diff --git a/analytic_hours_block/__openerp__.py b/analytic_hours_block/__openerp__.py index d6ae9142..a635ec1f 100644 --- a/analytic_hours_block/__openerp__.py +++ b/analytic_hours_block/__openerp__.py @@ -46,6 +46,7 @@ you can track and follow how much has been used. "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", diff --git a/analytic_hours_block/hours_block.py b/analytic_hours_block/hours_block.py index 85415a25..3ce24384 100644 --- a/analytic_hours_block/hours_block.py +++ b/analytic_hours_block/hours_block.py @@ -48,7 +48,7 @@ class AccountHoursBlock(orm.Model): # 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: diff --git a/analytic_hours_block/product.py b/analytic_hours_block/product.py new file mode 100644 index 00000000..3835799a --- /dev/null +++ b/analytic_hours_block/product.py @@ -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 . +# +############################################################################## + +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 + } diff --git a/analytic_hours_block/product_view.xml b/analytic_hours_block/product_view.xml new file mode 100644 index 00000000..c43fd0b3 --- /dev/null +++ b/analytic_hours_block/product_view.xml @@ -0,0 +1,18 @@ + + + + + + product.product.block.form + product.product + + +
+ +
+
+
+ +
+
From 3819092e7bf47d6f4880eb76f8eaa939545b7c40 Mon Sep 17 00:00:00 2001 From: Matthieu Dietrich Date: Wed, 2 Apr 2014 17:02:53 +0200 Subject: [PATCH 2/2] [FIX] add values to pot --- analytic_hours_block/i18n/analytic_hours_block.pot | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/analytic_hours_block/i18n/analytic_hours_block.pot b/analytic_hours_block/i18n/analytic_hours_block.pot index c90e8166..e8597111 100644 --- a/analytic_hours_block/i18n/analytic_hours_block.pot +++ b/analytic_hours_block/i18n/analytic_hours_block.pot @@ -458,3 +458,13 @@ msgstr "" msgid "Total" msgstr "" +#. module: analytic_hours_block +#: field:product.product,is_in_hours_block:0 +msgid "Accounted for hours block?" +msgstr "" + +#. module: analytic_hours_block +#: help:product.product,is_in_hours_block:0 +msgid "Specify if you want to have invoice lines containing this product to be considered for hours blocks." +msgstr "" +