Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Tryton
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tryton
Tryton
Commits
a0674871
Commit
a0674871
authored
4 years ago
by
Cédric Krier
Browse files
Options
Downloads
Patches
Plain Diff
Use depends on methods for carrier context
issue9492 review304001003
parent
0543457e
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
stock.py
+11
-14
11 additions, 14 deletions
stock.py
with
11 additions
and
14 deletions
stock.py
+
11
−
14
View file @
a0674871
...
...
@@ -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
co
mpany
=
Company
(
Transaction
().
context
[
'
company
'
])
context
[
'
amount
'
]
=
_percentage_amount
(
self
.
incoming_moves
,
company
)
context
[
'
currency
'
]
=
company
.
currency
.
id
co
ntext
[
'
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
co
mpany
=
Company
(
Transaction
().
context
[
'
company
'
])
context
[
'
amount
'
]
=
_percentage_amount
(
self
.
inventory_moves
,
company
)
context
[
'
currency
'
]
=
company
.
currency
.
id
co
ntext
[
'
amount
'
]
=
_percentage_amount
(
self
.
inventory_moves
,
self
.
company
)
context
[
'
currency
'
]
=
self
.
company
.
currency
.
id
return
context
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment