[IMP] Change product view for updating price, uom in product margin
bzr revid: jco@openerp.com-20130603151521-88glofqgcnu3u53o
This commit is contained in:
@@ -97,7 +97,7 @@
|
||||
<group name="procurement">
|
||||
<group name="general">
|
||||
<field name="cost_method" groups="product.group_costing_method"/>
|
||||
<field name="standard_price" attrs="{'readonly':[('cost_method','=','average')]}"/>
|
||||
<field name="standard_price" attrs="{'readonly':[('cost_method','in', ['average', 'standard'])]}"/>
|
||||
</group>
|
||||
<group name="procurement_uom" groups="product.group_uom" string="Purchase">
|
||||
<field name="uom_po_id"/>
|
||||
|
||||
@@ -56,16 +56,18 @@ class product_product(osv.osv):
|
||||
else:
|
||||
company_id = self.pool.get("res.users").browse(cr, uid, uid, context=context).company_id.id
|
||||
|
||||
#TODO: here we keep the property
|
||||
#Cost price is calculated afterwards as it is a property
|
||||
sqlstr="""select
|
||||
sum(l.price_unit * l.quantity)/sum(l.quantity) as avg_unit_price,
|
||||
sum(l.quantity) as num_qty,
|
||||
sum(l.price_unit * l.quantity)/sum(l.quantity * pu.factor / pu2.factor) as avg_unit_price,
|
||||
sum(l.quantity * pu.factor / pu2.factor) as num_qty,
|
||||
sum(l.quantity * (l.price_subtotal/l.quantity)) as total,
|
||||
sum(l.quantity * pt.list_price) as sale_expected
|
||||
sum(l.quantity * pu.factor * pt.list_price / pu2.factor) as sale_expected
|
||||
from account_invoice_line l
|
||||
left join account_invoice i on (l.invoice_id = i.id)
|
||||
left join product_product product on (product.id=l.product_id)
|
||||
left join product_template pt on (pt.id = l.product_id)
|
||||
left join product_uom pu on (pt.uom_id = pu.id)
|
||||
left join product_uom pu2 on (i.uos_id = pu2.id)
|
||||
where l.product_id = %s and i.state in %s and i.type IN %s and (i.date_invoice IS NULL or (i.date_invoice>=%s and i.date_invoice<=%s and i.company_id=%s))
|
||||
"""
|
||||
invoice_types = ('out_invoice', 'in_refund')
|
||||
|
||||
@@ -180,7 +180,7 @@
|
||||
-
|
||||
Purchase order in usd
|
||||
-
|
||||
I create a draft Purchase Order for 30 kg at 0.150 USD/g and 10 kg at 150 USD/kg
|
||||
I create a draft Purchase Order for 30000 g at 0.150 USD/g and 10 kg at 150 USD/kg
|
||||
-
|
||||
!record {model: purchase.order, id: purchase_order_fifo_usd}:
|
||||
partner_id: base.res_partner_3
|
||||
@@ -188,9 +188,9 @@
|
||||
pricelist_id: supplier_pricelist_usd
|
||||
order_line:
|
||||
- product_id: product_fifo_icecream
|
||||
product_qty: 30.0
|
||||
product_uom: product.product_uom_kgm
|
||||
price_unit: 150.0
|
||||
product_qty: 30000
|
||||
product_uom: product.product_uom_gram
|
||||
price_unit: 0.150
|
||||
name: 'FIFO Ice Cream'
|
||||
- product_id: product_fifo_icecream
|
||||
product_qty: 10.0
|
||||
@@ -208,7 +208,7 @@
|
||||
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [pick_ids[0].id]})
|
||||
self.do_partial(cr, uid, [partial_id])
|
||||
-
|
||||
We create delivery order of 49.500 kg
|
||||
We create delivery order of 49.5 kg
|
||||
-
|
||||
!record {model: stock.picking, id: outgoing_fifo_shipment_cur}:
|
||||
type: out
|
||||
@@ -219,7 +219,7 @@
|
||||
picking_id: outgoing_fifo_shipment_cur
|
||||
product_id: product_fifo_icecream
|
||||
product_uom: product.product_uom_kgm
|
||||
product_qty: 49.500
|
||||
product_qty: 49.5
|
||||
type: out
|
||||
-
|
||||
Process the delivery of the outgoing shipment
|
||||
@@ -228,7 +228,7 @@
|
||||
partial_id = self.create(cr, uid, {}, context={'active_model': 'stock.picking','active_ids': [ref("outgoing_fifo_shipment_cur")], 'default_type':'out'})
|
||||
self.do_partial(cr, uid, [partial_id])
|
||||
-
|
||||
Check rounded price is 102 euro = (30 kg * )
|
||||
Check rounded price is 102 euro
|
||||
-
|
||||
!python {model: product.product}: |
|
||||
assert round(self.browse(cr, uid, ref("product_fifo_icecream")).standard_price) == 102
|
||||
|
||||
@@ -134,9 +134,9 @@
|
||||
<field name="standard_price" position="replace" version="7.0">
|
||||
<label string="Cost Price" for="standard_price" align="1.0" groups="base.group_user"/>
|
||||
<div groups="base.group_user">
|
||||
<field name="standard_price" attrs="{'readonly':[('cost_method','=','average')]}" nolabel="1"/>
|
||||
<field name="standard_price" attrs="{'readonly':[('valuation','=','real_time'), ('cost_method', 'in', ['standard', 'average'])]}" nolabel="1"/>
|
||||
<button name="%(action_view_change_standard_price)d" string="- update"
|
||||
type="action" attrs="{'invisible':[('cost_method','<>','average')]}"
|
||||
type="action" attrs="{'invisible':['|', ('valuation','!=', 'real_time'), ('cost_method', 'not in', ['standard', 'average'])]}"
|
||||
class="oe_link" groups="product.group_costing_method"/>
|
||||
</div>
|
||||
</field>
|
||||
|
||||
Reference in New Issue
Block a user