46 lines
1.4 KiB
Python
46 lines
1.4 KiB
Python
# The COPYRIGHT file at the top level of this repository contains the full
|
|
# copyright notices and license terms.
|
|
from trytond.pool import PoolMeta
|
|
from trytond.model import fields
|
|
from trytond.pyson import Eval
|
|
from trytond.modules.document_cost_apply_invoice.cost import (
|
|
ApplyMethodCostMixin, ApplyMethodCostDocumentMixin)
|
|
|
|
__all__ = ['CostType', 'CostTemplate', 'SaleCost']
|
|
|
|
|
|
class CostType(ApplyMethodCostMixin):
|
|
__name__ = 'sale.cost.type'
|
|
__metaclass__ = PoolMeta
|
|
|
|
|
|
class CostTemplate:
|
|
__name__ = 'sale.cost.template'
|
|
__metaclass__ = PoolMeta
|
|
|
|
invoice_party = fields.Many2One('party.party', 'Invoice Party',
|
|
states={
|
|
'invisible': ~Eval('apply_method', '').in_(
|
|
['invoice_in', 'invoice_out'])
|
|
}, depends=['apply_method'])
|
|
|
|
def on_change_type_(self):
|
|
super(CostTemplate, self).on_change_type_()
|
|
if self.type_:
|
|
self.invoice_party = self.type_.invoice_party
|
|
|
|
|
|
class SaleCost(ApplyMethodCostDocumentMixin):
|
|
__name__ = 'sale.cost'
|
|
__metaclass__ = PoolMeta
|
|
|
|
def on_change_template(self):
|
|
super(SaleCost, self).on_change_template()
|
|
if self.template:
|
|
self.invoice_party = self.template.invoice_party
|
|
|
|
def on_change_type_(self):
|
|
super(SaleCost, self).on_change_type_()
|
|
if self.type_:
|
|
self.invoice_party = self.type_.invoice_party
|