Move cost price to product level instead of template
issue6515 review41321002
This commit is contained in:
1 parent
a993e29bfe
commit
cb9cc9dc37
3 files changed
+13
-50
No files matched your search
+8
-36
@@ -416,24 +416,13 @@ class UpdateCostPrice(Wizard):
|
||||
def default_ask_price(self, fields):
|
||||
pool = Pool()
|
||||
Product = pool.get('product.product')
|
||||
Template = pool.get('product.template')
|
||||
|
||||
context = Transaction().context
|
||||
default = {}
|
||||
if ('product' in fields
|
||||
and context['active_model'] == 'product.product'):
|
||||
product = Product(context['active_id'])
|
||||
template = product.template
|
||||
default['product'] = product.id
|
||||
elif ('template' in fields
|
||||
and context['active_model'] == 'product.template'):
|
||||
template = Template(context['active_id'])
|
||||
product = template.products[0]
|
||||
default['template'] = template.id
|
||||
else:
|
||||
return default
|
||||
default['cost_price'] = getattr(product, 'recompute_cost_price_%s' %
|
||||
product.cost_price_method)()
|
||||
product = Product(context['active_id'])
|
||||
default['product'] = product.id
|
||||
default['cost_price'] = getattr(
|
||||
product, 'recompute_cost_price_%s' % product.cost_price_method)()
|
||||
return default
|
||||
|
||||
@staticmethod
|
||||
@@ -441,12 +430,8 @@ class UpdateCostPrice(Wizard):
|
||||
'Return the product or template instance'
|
||||
pool = Pool()
|
||||
Product = pool.get('product.product')
|
||||
ProductTemplate = pool.get('product.template')
|
||||
context = Transaction().context
|
||||
if context['active_model'] == 'product.product':
|
||||
return Product(context['active_id'])
|
||||
else:
|
||||
return ProductTemplate(context['active_id'])
|
||||
return Product(context['active_id'])
|
||||
|
||||
@classmethod
|
||||
def get_quantity(cls):
|
||||
@@ -459,10 +444,7 @@ class UpdateCostPrice(Wizard):
|
||||
with Transaction().set_context(locations=[l.id for l in locations],
|
||||
stock_date_end=stock_date_end):
|
||||
product = cls.get_product()
|
||||
if hasattr(product.__class__, 'cost_price'):
|
||||
return product.quantity
|
||||
else:
|
||||
return product.template.quantity
|
||||
return product.quantity
|
||||
|
||||
def transition_should_show_move(self):
|
||||
if self.get_quantity() != 0:
|
||||
@@ -540,16 +522,6 @@ class UpdateCostPrice(Wizard):
|
||||
def transition_update_price(self):
|
||||
pool = Pool()
|
||||
Product = pool.get('product.product')
|
||||
ProductTemplate = pool.get('product.template')
|
||||
|
||||
if not isinstance(Product.cost_price, TemplateFunction):
|
||||
write = partial(Product.write, [self.ask_price.product])
|
||||
else:
|
||||
if self.ask_price.template:
|
||||
template = self.ask_price.template
|
||||
else:
|
||||
template = self.ask_price.product.template
|
||||
write = partial(ProductTemplate.write, [template])
|
||||
|
||||
write({'cost_price': self.ask_price.cost_price})
|
||||
self.ask_price.product.set_multivalue(
|
||||
'cost_price', self.ask_price.cost_price)
|
||||
return 'end'
|
||||
@@ -22,11 +22,6 @@ this repository contains the full copyright notices and license terms. -->
|
||||
<field name="model">product.product,-1</field>
|
||||
<field name="action" ref="wizard_update_cost_price"/>
|
||||
</record>
|
||||
<record model="ir.action.keyword" id="update_cost_price_template_keyword">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">product.template,-1</field>
|
||||
<field name="action" ref="wizard_update_cost_price"/>
|
||||
</record>
|
||||
<record model="ir.action-res.group"
|
||||
id="wizard_update_cost_price-group_account">
|
||||
<field name="action" ref="wizard_update_cost_price"/>
|
||||
|
||||
@@ -67,8 +67,6 @@ Create product::
|
||||
>>> ProductUom = Model.get('product.uom')
|
||||
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
|
||||
>>> ProductTemplate = Model.get('product.template')
|
||||
>>> Product = Model.get('product.product')
|
||||
>>> product = Product()
|
||||
>>> template = ProductTemplate()
|
||||
>>> template.name = 'product'
|
||||
>>> template.default_uom = unit
|
||||
@@ -76,7 +74,6 @@ Create product::
|
||||
>>> template.purchasable = True
|
||||
>>> template.salable = True
|
||||
>>> template.list_price = Decimal('10')
|
||||
>>> template.cost_price = Decimal('5')
|
||||
>>> template.cost_price_method = 'fixed'
|
||||
>>> template.lead_time = datetime.timedelta(0)
|
||||
>>> template.account_expense = expense
|
||||
@@ -86,15 +83,14 @@ Create product::
|
||||
>>> template.account_stock_customer = stock_customer
|
||||
>>> template.account_stock_production = stock_production
|
||||
>>> template.account_stock_lost_found = stock_lost_found
|
||||
>>> product, = template.products
|
||||
>>> product.cost_price = Decimal('5')
|
||||
>>> template.save()
|
||||
>>> product.template = template
|
||||
>>> product.save()
|
||||
>>> template_average, = ProductTemplate.duplicate([template], {
|
||||
>>> product, = template.products
|
||||
>>> template_average, = template.duplicate({
|
||||
... 'cost_price_method': 'average',
|
||||
... })
|
||||
>>> product_average, = Product.duplicate([product], {
|
||||
... 'template': template_average.id,
|
||||
... })
|
||||
>>> product_average, = template_average.products
|
||||
|
||||
Create payment term::
|
||||
|
||||
|
||||
Reference in new issue
Block a user