← Back to team overview

openerp-community-reviewer team mailing list archive

lp:~camptocamp/margin-analysis/7.0-port-product_standard_margin-yvr into lp:margin-analysis

 

Yannick Vaucher @ Camptocamp has proposed merging lp:~camptocamp/margin-analysis/7.0-port-product_standard_margin-yvr into lp:margin-analysis.

Requested reviews:
  Margin Analysis Core Editors (margin-analysis-core-editors)

For more details, see:
https://code.launchpad.net/~camptocamp/margin-analysis/7.0-port-product_standard_margin-yvr/+merge/190349

Portage of product_standard_margin
-- 
https://code.launchpad.net/~camptocamp/margin-analysis/7.0-port-product_standard_margin-yvr/+merge/190349
Your team Margin Analysis Core Editors is requested to review the proposed merge of lp:~camptocamp/margin-analysis/7.0-port-product_standard_margin-yvr into lp:margin-analysis.
=== modified file 'product_standard_margin/__openerp__.py'
--- product_standard_margin/__openerp__.py	2013-09-11 08:08:22 +0000
+++ product_standard_margin/__openerp__.py	2013-10-10 12:17:08 +0000
@@ -18,39 +18,39 @@
 #    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #
 ##############################################################################
-{'name' : 'Markup rate on product and sales',
- 'version' : '1.0',
- 'author' : 'Camptocamp',
+{'name': 'Markup rate on product and sales',
+ 'version': '1.0',
+ 'author': 'Camptocamp',
  'maintainer': 'Camptocamp',
  'category': 'Sales Management',
  'complexity': "normal",  # easy, normal, expert
- 'depends' : ['product_get_cost_field', 'account'],
+ 'depends': ['product_get_cost_field', 'account'],
  'description': """
   Add a field on the product form that compute the standard (or theorical) margin based on the
   current values of sale and cost price present in the product form. We take care of taxe included
   or excluded.
-  
-  It will just compute it as follow : (Sale Price without tax - Cost Price) / Sale Price without tax
-  
+
+  It will just compute it as follow: (Sale Price without tax - Cost Price) / Sale Price without tax
+
   Remember that this module can be used in conjonction with product_cost_incl_bom to have the 
   cost price computed from the BOM when a product has one.
-  
-  WARNING: 
-  
+
+  WARNING:
+
   1) As this module will base his simple computation on sale and cost prices, it suppose
   you have them both in the same currency (the price type must of the same currency for both of 
   them). Remember this is the default OpenERP configuration (price type of all product price 
   fields are set as the same as the company currency). We don't take care of it cause otherwise
   we should have added a dependency on sale module.
-  
-  
+
+
   """,
  'website': 'http://www.camptocamp.com/',
  'init_xml': [],
  'update_xml': ['product_std_margin_view.xml'],
  'demo_xml': [],
  'tests': [],
- 'installable': False,
+ 'installable': True,
  'auto_install': False,
  'license': 'AGPL-3',
  'application': True}

=== modified file 'product_standard_margin/product_std_margin.py'
--- product_standard_margin/product_std_margin.py	2012-07-12 13:56:17 +0000
+++ product_standard_margin/product_std_margin.py	2013-10-10 12:17:08 +0000
@@ -28,7 +28,7 @@
 
 class Product(Model):
     _inherit = 'product.product'
-    
+
     #TODO : compute the margin with default taxes
     def _amount_tax_excluded(self, cr, uid, ids, context=None):
         """
@@ -49,19 +49,19 @@
             taxes = tax_obj.compute_all(cr, uid, prod.taxes_id, price, 1, product=prod.id)
             res[prod.id] = taxes['total']
         return res
-        
+
     def _compute_margin(self, cursor, user, ids, field_name, arg, context = None):
         """
         Calculate the margin based on product infos. Take care of the cost_field 
         define in product_get_cost_field. So the margin will be computed based on this 
         field.
-        
+
         We don't take care of the product price type currency to remove the dependency on
         the sale module. We consider the cost and sale price is in the company currency.
-        
+
         We take care of the default product taxes, and base our computation on total without 
         tax.
-        
+
         :return dict of dict of the form : 
             {INT Product ID : {
                 {'margin_absolute': float, 
@@ -79,7 +79,6 @@
         for product in self.browse(cursor, user, ids):
             cost = product.cost_price
             sale = self._amount_tax_excluded(cursor, user, [product.id], context=context)[product.id]
-            # sale = product.list_price
             res[product.id]['standard_margin'] = sale - cost
             if sale == 0:
                 logger.debug("Sale price for product ID %d is 0, cannot compute margin rate...", product.id)
@@ -89,18 +88,20 @@
         return res
 
     _columns = {
-        'standard_margin' : fields.function(_compute_margin,
-                                              method=True,
-                                              string='Theorical Margin',
-                                              digits_compute=dp.get_precision('Sale Price'),
-                                              multi ='margin',
-                                              help='Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values).'
-                                              'Take care of tax include and exclude. If no sale price, the margin will be negativ.'),
-        'standard_margin_rate' : fields.function(_compute_margin,
-                                        method=True,
-                                        string='Theorical Margin (%)',
-                                        digits_compute=dp.get_precision('Sale Price'),
-                                        multi='margin',
-                                        help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).'
-                                        'Take care of tax include and exclude.. If no sale price set, will display 999.0'),
+        'standard_margin': fields.function(
+                _compute_margin,
+               method=True,
+               string='Theorical Margin',
+               digits_compute=dp.get_precision('Sale Price'),
+               multi ='margin',
+               help='Theorical Margin is [ sale price (Wo Tax) - cost price ] of the product form (not based on historical values).'
+               'Take care of tax include and exclude. If no sale price, the margin will be negativ.'),
+        'standard_margin_rate': fields.function(
+                _compute_margin,
+                method=True,
+                string='Theorical Margin (%)',
+                digits_compute=dp.get_precision('Sale Price'),
+                multi='margin',
+                help='Markup rate is [ Theorical Margin / sale price (Wo Tax) ] of the product form (not based on historical values).'
+                'Take care of tax include and exclude.. If no sale price set, will display 999.0'),
         }

=== modified file 'product_standard_margin/product_std_margin_view.xml'
--- product_standard_margin/product_std_margin_view.xml	2012-07-12 13:56:17 +0000
+++ product_standard_margin/product_std_margin_view.xml	2013-10-10 12:17:08 +0000
@@ -7,13 +7,12 @@
       <field name="model">product.product</field>
       <field name="inherit_id" ref="product.product_normal_form_view" />
       <field name="arch" type="xml">
-          <group colspan="2" col="2" groups="base.group_extended" position="after">
-              <group colspan="2" col="2" groups="base.group_extended">
-                  <separator string="Margin" colspan="2"/>
-                  <field name="standard_margin" />
-                  <field name="standard_margin_rate" />
-              </group>
+        <xpath expr="//field[@name='price_margin']/.." position="after">
+          <group name="Margin" groups="base.group_extended">
+            <field name="standard_margin" />
+            <field name="standard_margin_rate" />
           </group>
+        </xpath>
       </field>
     </record>
 


Follow ups