Skip to content
Snippets Groups Projects
Commit a0674871 authored by Cédric Krier's avatar Cédric Krier :atom:
Browse files

Use depends on methods for carrier context

issue9492
review304001003
parent 0543457e
No related branches found
No related tags found
No related merge requests found
......@@ -2,4 +2,5 @@
# this repository contains the full copyright notices and license terms.
from decimal import Decimal
from trytond.model import fields
from trytond.pool import Pool, PoolMeta
......@@ -5,5 +6,4 @@
from trytond.pool import Pool, PoolMeta
from trytond.transaction import Transaction
def _percentage_amount(lines, company):
......@@ -31,4 +31,5 @@
class ShipmentIn(metaclass=PoolMeta):
__name__ = 'stock.shipment.in'
@fields.depends('carrier', 'incoming_moves', 'company')
def _get_carrier_context(self):
......@@ -34,3 +35,2 @@
def _get_carrier_context(self):
Company = Pool().get('company.company')
context = super(ShipmentIn, self)._get_carrier_context()
......@@ -36,3 +36,3 @@
context = super(ShipmentIn, self)._get_carrier_context()
if not self.carrier:
if not self.carrier or not self.company:
return context
......@@ -38,4 +38,3 @@
return context
context = context.copy()
if self.carrier.carrier_cost_method != 'percentage':
return context
......@@ -40,11 +39,11 @@
if self.carrier.carrier_cost_method != 'percentage':
return context
company = Company(Transaction().context['company'])
context['amount'] = _percentage_amount(self.incoming_moves, company)
context['currency'] = company.currency.id
context['amount'] = _percentage_amount(
self.incoming_moves, self.company)
context['currency'] = self.company.currency.id
return context
class ShipmentOut(metaclass=PoolMeta):
__name__ = 'stock.shipment.out'
......@@ -45,7 +44,8 @@
return context
class ShipmentOut(metaclass=PoolMeta):
__name__ = 'stock.shipment.out'
@fields.depends('carrier', 'inventory_moves', 'company')
def _get_carrier_context(self):
......@@ -51,4 +51,2 @@
def _get_carrier_context(self):
Company = Pool().get('company.company')
context = super(ShipmentOut, self)._get_carrier_context()
......@@ -54,3 +52,3 @@
context = super(ShipmentOut, self)._get_carrier_context()
if not self.carrier:
if not self.carrier or not self.company:
return context
......@@ -56,4 +54,3 @@
return context
context = context.copy()
if self.carrier.carrier_cost_method != 'percentage':
return context
......@@ -58,6 +55,6 @@
if self.carrier.carrier_cost_method != 'percentage':
return context
company = Company(Transaction().context['company'])
context['amount'] = _percentage_amount(self.inventory_moves, company)
context['currency'] = company.currency.id
context['amount'] = _percentage_amount(
self.inventory_moves, self.company)
context['currency'] = self.company.currency.id
return context
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment