savoirfairelinux-openerp team mailing list archive
-
savoirfairelinux-openerp team
-
Mailing list archive
-
Message #00202
[Merge] lp:~savoirfairelinux-openerp/c2c-rd-addons/7.0-fix-1199994 into lp:c2c-rd-addons/7.0
David Cormier has proposed merging lp:~savoirfairelinux-openerp/c2c-rd-addons/7.0-fix-1199994 into lp:c2c-rd-addons/7.0.
Requested reviews:
Camptocamp (camptocamp)
Related bugs:
Bug #1199994 in Camptocamp R&D Addons: "Cannot override landed cost distribution in landed cost line"
https://bugs.launchpad.net/c2c-rd-addons/+bug/1199994
For more details, see:
https://code.launchpad.net/~savoirfairelinux-openerp/c2c-rd-addons/7.0-fix-1199994/+merge/176778
Fixes bug #1199994
--
https://code.launchpad.net/~savoirfairelinux-openerp/c2c-rd-addons/7.0-fix-1199994/+merge/176778
Your team Savoir-faire Linux' OpenERP is subscribed to branch lp:~savoirfairelinux-openerp/c2c-rd-addons/7.0-fix-1199994.
=== modified file 'purchase_landed_costs/product.py'
--- purchase_landed_costs/product.py 2012-04-17 07:35:23 +0000
+++ purchase_landed_costs/product.py 2013-07-24 20:24:26 +0000
@@ -36,6 +36,13 @@
'landed_cost' :fields.boolean('Calculate Landed Costs', help="Check this if you want to use landed cost calculation for average price for this product"),
}
+ _defaults = {
+ 'landed_cost_type': lambda self, cr, uid, context:
+ context['landed_cost_type'] if 'landed_cost_type'\
+ in context else None
+
+ }
+
product_template()
class product_category(osv.osv):
=== modified file 'purchase_landed_costs/purchase.py'
--- purchase_landed_costs/purchase.py 2013-02-07 09:31:34 +0000
+++ purchase_landed_costs/purchase.py 2013-07-24 20:24:26 +0000
@@ -80,17 +80,25 @@
def _landing_cost_order(self, cr, uid, ids, name, args, context):
if not ids : return {}
result = {}
- # landed costss for the line
+ # landed costs for the line
for line in self.browse(cr, uid, ids):
landed_costs = 0.0
- # distrubution of landed costs of PO
+ # distribution of landed costs of PO
if line.order_id.landed_cost_line_ids:
- landed_costs += line.order_id.landed_cost_base_value / line.order_id.amount_total * line.price_subtotal + \
+ landed_costs += line.order_id.landed_cost_base_value / line.order_id.amount_total * line.price_subtotal + \
line.order_id.landed_cost_base_quantity / line.order_id.quantity_total * line.product_qty
result[line.id] = landed_costs
return result
+ def _landing_cost_factor(self, cr, uid, ids, name, args, context):
+ """
+ Calculates the percentage of landing costs that should be put on this order line
+ """
+ for line in self.browse(cr, uid, ids):
+ if line.landed_cost_line_ids:
+ pass
+
def _landed_cost(self, cr, uid, ids, name, args, context):
if not ids : return {}
@@ -124,7 +132,7 @@
for line in self.browse(cr, uid, ids):
if line.landed_cost_line_ids:
for costs in line.landed_cost_line_ids:
- if costs.product_id.landed_cost_type == 'value':
+ if costs.price_type == 'value':
landed_costs_base_value += costs.amount
result[line.id] = landed_costs_base_value
return result
@@ -136,7 +144,7 @@
for line in self.browse(cr, uid, ids):
if line.landed_cost_line_ids:
for costs in line.landed_cost_line_ids:
- if costs.product_id.landed_cost_type == 'per_unit':
+ if costs.price_type == 'per_unit':
landed_costs_base_quantity += costs.amount
result[line.id] = landed_costs_base_quantity
return result
@@ -198,6 +206,16 @@
return res
+ def _get_product_account_expense_id(self, product):
+ """
+ Returns the product's account expense id if present
+ or it's parent categories account expense id otherwise
+ """
+ if product.property_account_expense.id:
+ return product.property_account_expense.id
+ return product.categ_id.property_account_expense_categ.id
+
+
def _create_pickings(self, cr, uid, order, order_lines, picking_id=False, context=None):
res = super(purchase_order,self)._create_pickings(cr, uid, order, order_lines, picking_id, context)
pick_id = int(res[0])
@@ -230,7 +248,7 @@
#,'amount' : order_cost.amount
#,'amount_currency' : order_cost.amount_currency
#,'picking_id' : pick_id
- ,'account_id' : order_cost.product_id.property_account_expense.id
+ ,'account_id' : self._get_product_account_expense_id(order_cost.product_id)
,'partner_id' : order_cost.partner_id.id
,'invoice_id' : inv_id
,'price_unit' : order_cost.amount
=== modified file 'purchase_landed_costs/purchase_view.xml'
--- purchase_landed_costs/purchase_view.xml 2013-02-07 09:15:39 +0000
+++ purchase_landed_costs/purchase_view.xml 2013-07-24 20:24:26 +0000
@@ -9,7 +9,7 @@
<field name="type">tree</field>
<field name="arch" type="xml">
<tree string="Landing Costs" editable="bottom">
- <field name="product_id" on_change="onchange_product_id(product_id)"/>
+ <field name="product_id" context="{'landed_cost_type':'per_unit'}" on_change="onchange_product_id(product_id)"/>
<field name="partner_id"/>
<field name="amount"/>
<field name="price_type"/>
Follow ups