semillero-151 Gestión de costes: Distribuir el coste de los movimientos "in" de una producción so..., tarea y varias refacturaciones
This commit is contained in:
parent
364377862d
commit
eba6d5086e
|
@ -3,9 +3,11 @@
|
|||
|
||||
from trytond.pool import Pool
|
||||
from .cost_manage import CostDistribution
|
||||
from .production import Production
|
||||
|
||||
|
||||
def register():
|
||||
Pool.register(
|
||||
Production,
|
||||
CostDistribution,
|
||||
module='production_cost_manage', type_='model')
|
|
@ -15,6 +15,6 @@ class CostDistribution:
|
|||
@classmethod
|
||||
def _get_cost_center(cls):
|
||||
"""Return list of Model names for Cost source Reference"""
|
||||
sources = super(CostDistribution, cls)._get_cost_center()
|
||||
sources.append('production')
|
||||
return sources
|
||||
cost_centers = super(CostDistribution, cls)._get_cost_center()
|
||||
cost_centers.append('production')
|
||||
return cost_centers
|
|
@ -0,0 +1,51 @@
|
|||
#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
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.modules.cost_manage import ComposeCostSource, CostCenter
|
||||
|
||||
__all__ = ['Production']
|
||||
|
||||
__metaclass__ = PoolMeta
|
||||
|
||||
|
||||
class Production(ComposeCostSource, CostCenter):
|
||||
|
||||
__name__ = 'production'
|
||||
|
||||
@fields.depends('effective_date')
|
||||
def on_change_with_cost_date(self, field=None):
|
||||
return getattr(self, 'effective_date', None)
|
||||
|
||||
def get_son_sources(self):
|
||||
return self.inputs
|
||||
|
||||
@fields.depends('company')
|
||||
def on_change_with_currency_digits(self, name=None):
|
||||
if self.company:
|
||||
return self.company.currency.digits
|
||||
return 2
|
||||
|
||||
@classmethod
|
||||
def _manage_input_cost(cls, productions):
|
||||
|
||||
cls.distribute([p.id for p in productions])
|
||||
|
||||
pool = Pool()
|
||||
|
||||
models = [pool.get('cost.manage.distribution.rule'), pool.get('cost.manage.cost.distribution')]
|
||||
distributions = cls.search_details(models[1], productions, active_test=False, status='stable')
|
||||
models[1].delete(distributions)
|
||||
for model in models:
|
||||
details = cls.search_details(model, productions, status='added')
|
||||
model.write(details, dict(status='stable'))
|
||||
|
||||
@classmethod
|
||||
def run(cls, productions):
|
||||
super(Production, cls).run(productions)
|
||||
cls._manage_input_cost(productions)
|
||||
|
||||
@classmethod
|
||||
def done(cls, productions):
|
||||
super(Production, cls).done(productions)
|
||||
cls._manage_input_cost(productions)
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<tryton>
|
||||
<data>
|
||||
<record model="ir.action.keyword" id="distribute_keyword">
|
||||
<field name="keyword">form_action</field>
|
||||
<field name="model">production,-1</field>
|
||||
<field name="action" ref="cost_manage.wizard_distribute"/>
|
||||
</record>
|
||||
|
||||
<!--record model="ir.ui.view" id="timesheet_team_timesheet_view_form">
|
||||
<field name="model">timesheet.team.timesheet</field>
|
||||
<field name="type">form</field>
|
||||
<field name="inherit" ref="team_timesheet.timesheet_team_timesheet_view_form"/>
|
||||
<field name="name">timesheet_team_timesheet_form</field>
|
||||
</record-->
|
||||
|
||||
|
||||
<!-- Rule Types -->
|
||||
<record model="cost.manage.distribution.rule.type" id="distribution_rule_type_production_inputs">
|
||||
<field name="code">production_inputs</field>
|
||||
<field name="name">production_inputs</field>
|
||||
<field name="cost_center_model" search="[('model', '=', 'production')]"/>
|
||||
<field name="domain">[('inputs', '=', %(cost_source)s)]</field>
|
||||
<field name="parameter_aliases"></field>
|
||||
<field name="is_automatic">True</field>
|
||||
<field name="active">True</field>
|
||||
</record>
|
||||
<record model="cost.manage.distribution.rule.type-ir.model" id="rule_type-ir_model_production_inputs-production">
|
||||
<field name="rule_type" ref="distribution_rule_type_production_inputs"/>
|
||||
<field name="cost_source_model" search="[('model', '=', 'stock.move')]"/>
|
||||
</record>
|
||||
</data>
|
||||
</tryton>
|
|
@ -2,4 +2,6 @@
|
|||
version=3.2.1
|
||||
depends:
|
||||
cost_manage
|
||||
production
|
||||
production
|
||||
xml:
|
||||
production_cost_manage.xml
|
||||
|
|
Loading…
Reference in New Issue