Store directly sequence type to sequence

This commit is contained in:
Albert Cervera i Areny 2021-03-20 02:05:12 +01:00
parent 7e5bd801db
commit b65280218c
3 changed files with 7 additions and 9 deletions

View File

@ -1,7 +1,7 @@
# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from trytond.model import fields, ModelSQL
from trytond.pyson import Eval
from trytond.pyson import Eval, Id
from trytond.pool import PoolMeta, Pool
from trytond.modules.company.model import (
CompanyMultiValueMixin, CompanyValueMixin)
@ -17,7 +17,8 @@ class Configuration(CompanyMultiValueMixin, metaclass=PoolMeta):
'Product Cost Plan Sequence', domain=[
('company', 'in',
[Eval('context', {}).get('company', -1), None]),
('code', '=', 'product_cost_plan'),
('sequence_type', '=', Id('product_cost_plan',
'sequence_type_product_cost_plan')),
], required=True))
@classmethod
@ -36,5 +37,6 @@ class ConfigurationProductcostPlan(ModelSQL, CompanyValueMixin):
'Product Cost Plan Sequence', domain=[
('company', 'in',
[Eval('context', {}).get('company', -1), None]),
('code', '=', 'product_cost_plan'),
('sequence_type', '=', Id('product_cost_plan',
'sequence_type_product_cost_plan')),
], required=True)

View File

@ -446,15 +446,12 @@ class Plan(ModelSQL, ModelView):
@classmethod
def create(cls, vlist):
Sequence = Pool().get('ir.sequence')
Config = Pool().get('production.configuration')
vlist = [x.copy() for x in vlist]
config = Config(1)
for values in vlist:
values['number'] = Sequence.get_id(
config.product_cost_plan_sequence and
config.product_cost_plan_sequence.id)
values['number'] = config.product_cost_plan_sequence.get()
return super(Plan, cls).create(vlist)
@classmethod

View File

@ -19,7 +19,6 @@
</record>
<record model="ir.sequence.type" id="sequence_type_product_cost_plan">
<field name="name">Product Cost Plan</field>
<field name="code">product_cost_plan</field>
</record>
<record model="ir.sequence.type-res.group"
id="sequence_type_product_cost_plan_group_admin">
@ -34,7 +33,7 @@
<record model="ir.sequence" id="sequence_product_cost_plan">
<field name="name">Product Cost Plan</field>
<field name="code">product_cost_plan</field>
<field name="sequence_type" ref="sequence_type_product_cost_plan"/>
</record>
<!-- product.cost.plan -->