Create productions in draft and don't use plan's prices in sale line

This commit is contained in:
Guillem Barba 2015-01-19 19:22:19 +01:00
parent 3b4b1b1aa9
commit b1797b7f11
8 changed files with 28 additions and 38 deletions

View File

@ -1,2 +1,6 @@
Version 3.4.1 - 2015-01-19
* Create productions in draft state
* Don't use plan's price in sale line
Version 3.4.0 - 2014-11-03
* Initial release

View File

@ -1,4 +1,4 @@
Copyright (C) 2013 NaN·tic
Copyright (C) 2014-15 NaN·tic
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by

View File

@ -8,7 +8,6 @@ from .sale import *
def register():
Pool.register(
Product,
Production,
Plan,
PlanBOM,

View File

@ -2,6 +2,14 @@
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:product.cost.plan:"
msgid ""
"No production can be created because Product Cost Plan \"%s\" has no BOM "
"assigned."
msgstr ""
"No es pot crear cap producció perquè el pla de cost \"%s\" no té una LdM "
"associada."
msgctxt "field:production,cost_plan:"
msgid "Cost Plan"
msgstr "Pla de costos"

View File

@ -2,6 +2,14 @@
msgid ""
msgstr "Content-Type: text/plain; charset=utf-8\n"
msgctxt "error:product.cost.plan:"
msgid ""
"No production can be created because Product Cost Plan \"%s\" has no BOM "
"assigned."
msgstr ""
"No se puede crear la producción porque el plan de costes \"%s\" no tiene LdM"
" asociada."
msgctxt "field:production,cost_plan:"
msgid "Cost Plan"
msgstr "Plan de costes"

View File

@ -100,7 +100,10 @@ class Plan:
return res
def get_production_data(self):
return {'product': self.product, 'bom': self.bom}
return {
'product': self.product,
'bom': self.bom,
}
def _get_production(self, values):
"Returns the production values to create for the especified bom"
@ -118,7 +121,7 @@ class Plan:
production = Production()
production.company = Company(context.get('company'))
production.state = 'request'
production.state = 'draft'
production.quantity = values['quantity']
production.product = values['product']

34
sale.py
View File

@ -5,25 +5,10 @@ from trytond.pool import PoolMeta, Pool
from trytond.pyson import Eval
from trytond.transaction import Transaction
__all__ = ['Product', 'Sale', 'SaleLine']
__all__ = ['Sale', 'SaleLine']
__metaclass__ = PoolMeta
class Product:
__name__ = 'product.product'
@classmethod
def get_sale_price(cls, products, quantity=0):
CostPlan = Pool().get('product.cost.plan')
res = super(Product, cls).get_sale_price(products, quantity)
cost_plan = Transaction().context.get('cost_plan')
if cost_plan:
unit_price = CostPlan(cost_plan).unit_price
for x in res.keys():
res[x] = unit_price
return res
class Sale:
__name__ = 'sale.sale'
@ -72,13 +57,6 @@ class SaleLine:
depends=['type', 'product'])
productions = fields.One2Many('production', 'origin', 'Productions')
@classmethod
def __setup__(cls):
super(SaleLine, cls).__setup__()
for field in cls.quantity.on_change:
if field not in cls.cost_plan.on_change:
cls.cost_plan.on_change.add(field)
@fields.depends('cost_plan', 'product')
def on_change_product(self):
CostPlan = Pool().get('product.cost.plan')
@ -93,16 +71,6 @@ class SaleLine:
res['cost_plan'] = plan.id if plan else None
return res
def on_change_cost_plan(self):
return self.on_change_quantity()
def _get_context_sale_price(self):
context = super(SaleLine, self)._get_context_sale_price()
if hasattr(self, 'cost_plan'):
context['cost_plan'] = (self.cost_plan.id
if self.cost_plan else None)
return context
def get_productions(self):
if not self.cost_plan:
return []

View File

@ -1,5 +1,5 @@
[tryton]
version=3.4.0
version=3.4.1
depends:
product_cost_plan_margin
production_origin