Fix path error and update issue9274 patch
This commit is contained in:
parent
f077781d55
commit
a3f4785072
121
issue9274.diff
121
issue9274.diff
|
@ -1,8 +1,8 @@
|
|||
diff --git a/__init__.py b/__init__.py
|
||||
index 06b209f..be74293 100644
|
||||
--- a/__init__.py
|
||||
+++ b/__init__.py
|
||||
@@ -1,13 +1,15 @@
|
||||
index 06b209f..48f9eb6 100644
|
||||
--- a/trytond/trytond/modules/product_cost_fifo/__init__.py
|
||||
+++ b/trytond/trytond/modules/product_cost_fifo/__init__.py
|
||||
@@ -1,13 +1,16 @@
|
||||
# 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.pool import Pool
|
||||
|
@ -22,41 +22,75 @@ index 06b209f..be74293 100644
|
|||
+ product.Product,
|
||||
+ move.Move,
|
||||
+ configuration.Configuration,
|
||||
+ configuration.ConfigurationExcludeLocations,
|
||||
module='product_cost_fifo', type_='model')
|
||||
diff --git a/configuration.py b/configuration.py
|
||||
new file mode 100644
|
||||
index 0000000..e4e44fc
|
||||
index 0000000..9d761ed
|
||||
--- /dev/null
|
||||
+++ b/configuration.py
|
||||
@@ -0,0 +1,23 @@
|
||||
+++ b/trytond/trytond/modules/product_cost_fifo/configuration.py
|
||||
@@ -0,0 +1,56 @@
|
||||
+# 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
|
||||
+from trytond import backend
|
||||
+from trytond.model import fields, ModelSQL
|
||||
+from trytond.pool import Pool, PoolMeta
|
||||
+from trytond.pyson import Eval
|
||||
+from trytond.tools.multivalue import migrate_property
|
||||
+from trytond.modules.company.model import CompanyValueMixin
|
||||
+
|
||||
+__all__ = ['Configuration']
|
||||
+__all__ = ['Configuration', 'ConfigurationExcludeLocations']
|
||||
+
|
||||
+
|
||||
+class Configuration(metaclass=PoolMeta):
|
||||
+ __name__ = 'stock.configuration'
|
||||
+
|
||||
+ exclude_locations = fields.Many2Many('stock.locations', None, None,
|
||||
+ 'Exclude Locations')
|
||||
+ exclude_location = fields.MultiValue(fields.Many2One(
|
||||
+ 'stock.location', "Exclude Location",
|
||||
+ domain=[
|
||||
+ ('type', '=', 'warehouse'),
|
||||
+ ]))
|
||||
+
|
||||
+ @classmethod
|
||||
+ def multivalue_model(cls, field):
|
||||
+ if field == 'exclude_location':
|
||||
+ return Pool().get('stock.configuration.exclude_location')
|
||||
+ return super().multivalue_model(field)
|
||||
+
|
||||
+
|
||||
+class ConfigurationExcludeLocations(ModelSQL, CompanyValueMixin):
|
||||
+ "Configuration Exlcude Location"
|
||||
+ __name__ = 'stock.configuration.exclude_location'
|
||||
+
|
||||
+ exclude_location = fields.Many2One(
|
||||
+ 'stock.location', "Exclude Location",
|
||||
+ domain=[
|
||||
+ ('type', '=', 'warehouse'),
|
||||
+ ])
|
||||
+
|
||||
+ @classmethod
|
||||
+ def __register__(cls, module_name):
|
||||
+ table = cls.__table_handler__(module_name)
|
||||
+ TableHandler = backend.get('TableHandler')
|
||||
+ exist = TableHandler.table_exist(cls._table)
|
||||
+
|
||||
+ # Migration from 5.2: rename reference into valued_sale_line
|
||||
+ if (table.column_exist('valued_sale_line')):
|
||||
+ table.column_rename('valued_sale_line', 'valued_origin')
|
||||
+ super().__register__(module_name)
|
||||
+
|
||||
+ super(Configuration, cls).__register__(module_name)
|
||||
+ if not exist:
|
||||
+ cls._migrate_property([], [], [])
|
||||
+
|
||||
+ @classmethod
|
||||
+ def _migrate_property(cls, field_names, value_names, fields):
|
||||
+ field_names.extend('exclude_location')
|
||||
+ value_names.extend('exclude_location')
|
||||
+ fields.append('company')
|
||||
+ migrate_property(
|
||||
+ 'stock.configuration', field_names, cls, value_names,
|
||||
+ fields=fields)
|
||||
diff --git a/configuration.xml b/configuration.xml
|
||||
new file mode 100644
|
||||
index 0000000..d1a8c9a
|
||||
--- /dev/null
|
||||
+++ b/configuration.xml
|
||||
+++ b/trytond/trytond/modules/product_cost_fifo/configuration.xml
|
||||
@@ -0,0 +1,12 @@
|
||||
+<?xml version="1.0"?>
|
||||
+<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
|
@ -72,8 +106,8 @@ index 0000000..d1a8c9a
|
|||
+</tryton>
|
||||
diff --git a/move.py b/move.py
|
||||
index 91a7b07..a7393dd 100644
|
||||
--- a/move.py
|
||||
+++ b/move.py
|
||||
--- a/trytond/trytond/modules/product_cost_fifo/move.py
|
||||
+++ b/trytond/trytond/modules/product_cost_fifo/move.py
|
||||
@@ -81,13 +81,15 @@ class Move(metaclass=PoolMeta):
|
||||
to_save = []
|
||||
for move, move_qty in fifo_moves:
|
||||
|
@ -98,9 +132,9 @@ index 91a7b07..a7393dd 100644
|
|||
|
||||
move_qty = Uom.compute_qty(self.product.default_uom, move_qty,
|
||||
diff --git a/product.py b/product.py
|
||||
index 9eaceac..2ad49a2 100644
|
||||
--- a/product.py
|
||||
+++ b/product.py
|
||||
index 9eaceac..8b5aa0a 100644
|
||||
--- a/trytond/trytond/modules/product_cost_fifo/product.py
|
||||
+++ b/trytond/trytond/modules/product_cost_fifo/product.py
|
||||
@@ -31,7 +31,7 @@ class Product(metaclass=PoolMeta):
|
||||
domain = [
|
||||
('product', '=', self.id),
|
||||
|
@ -110,10 +144,11 @@ index 9eaceac..2ad49a2 100644
|
|||
('to_location.type', '=', 'storage'),
|
||||
]
|
||||
if not date:
|
||||
@@ -95,7 +95,10 @@ class Product(metaclass=PoolMeta):
|
||||
@@ -95,7 +95,11 @@ class Product(metaclass=PoolMeta):
|
||||
Move = pool.get('stock.move')
|
||||
Currency = pool.get('currency.currency')
|
||||
Uom = pool.get('product.uom')
|
||||
+ Location = pool.get('stock.location')
|
||||
+ Config = pool.get('stock.configuration')
|
||||
+
|
||||
digits = self.__class__.cost_price.digits
|
||||
|
@ -121,13 +156,16 @@ index 9eaceac..2ad49a2 100644
|
|||
|
||||
domain = [
|
||||
('product', '=', self.id),
|
||||
@@ -111,6 +114,14 @@ class Product(metaclass=PoolMeta):
|
||||
@@ -111,6 +115,17 @@ class Product(metaclass=PoolMeta):
|
||||
],
|
||||
],
|
||||
]
|
||||
+
|
||||
+ if config.exclude_values:
|
||||
+ locations_ids = [l.id for l in config.exclude_locations]
|
||||
+ if config.exclude_location:
|
||||
+ locations = Location.search([
|
||||
+ ('parent', 'child_of', [config.exclude_location]),
|
||||
+ ])
|
||||
+ location_ids = list(set(x.id for x in locations))
|
||||
+ domain.extend([
|
||||
+ ('to_location.id', 'not in', location_ids),
|
||||
+ ('from_location.id', 'not in', location_ids),
|
||||
|
@ -136,7 +174,7 @@ index 9eaceac..2ad49a2 100644
|
|||
if start:
|
||||
domain.append(('effective_date', '>=', start))
|
||||
moves = Move.search(
|
||||
@@ -135,11 +146,10 @@ class Product(metaclass=PoolMeta):
|
||||
@@ -135,11 +150,10 @@ class Product(metaclass=PoolMeta):
|
||||
quantity = Decimal(str(quantity))
|
||||
|
||||
def in_move(move):
|
||||
|
@ -150,7 +188,7 @@ index 9eaceac..2ad49a2 100644
|
|||
|
||||
def compute_fifo_cost_price(quantity, date):
|
||||
fifo_moves = self.get_fifo_move(
|
||||
@@ -150,12 +160,15 @@ class Product(metaclass=PoolMeta):
|
||||
@@ -150,12 +164,15 @@ class Product(metaclass=PoolMeta):
|
||||
consumed_qty = 0
|
||||
for move, move_qty in fifo_moves:
|
||||
consumed_qty += move_qty
|
||||
|
@ -172,7 +210,7 @@ index 9eaceac..2ad49a2 100644
|
|||
cost_price += unit_price * Decimal(str(move_qty))
|
||||
if consumed_qty:
|
||||
return (cost_price / Decimal(str(consumed_qty))).quantize(
|
||||
@@ -163,7 +176,8 @@ class Product(metaclass=PoolMeta):
|
||||
@@ -163,7 +180,8 @@ class Product(metaclass=PoolMeta):
|
||||
|
||||
current_moves = []
|
||||
current_out_qty = 0
|
||||
|
@ -182,7 +220,7 @@ index 9eaceac..2ad49a2 100644
|
|||
for move in moves:
|
||||
if (current_moves
|
||||
and current_moves[-1].effective_date
|
||||
@@ -202,12 +216,15 @@ class Product(metaclass=PoolMeta):
|
||||
@@ -202,12 +220,15 @@ class Product(metaclass=PoolMeta):
|
||||
if move.from_location.type == 'storage':
|
||||
qty *= -1
|
||||
if in_move(move):
|
||||
|
@ -204,7 +242,7 @@ index 9eaceac..2ad49a2 100644
|
|||
if quantity + qty > 0 and quantity >= 0:
|
||||
cost_price = (
|
||||
(cost_price * quantity) + (unit_price * qty)
|
||||
@@ -216,7 +233,7 @@ class Product(metaclass=PoolMeta):
|
||||
@@ -216,7 +237,7 @@ class Product(metaclass=PoolMeta):
|
||||
cost_price = unit_price
|
||||
current_cost_price = cost_price.quantize(
|
||||
Decimal(str(10.0 ** -digits[1])))
|
||||
|
@ -215,8 +253,8 @@ index 9eaceac..2ad49a2 100644
|
|||
|
||||
diff --git a/tests/scenario_product_cost_fifo_recompute_cost_price.rst b/tests/scenario_product_cost_fifo_recompute_cost_price.rst
|
||||
index f8b952f..d4f906d 100644
|
||||
--- a/tests/scenario_product_cost_fifo_recompute_cost_price.rst
|
||||
+++ b/tests/scenario_product_cost_fifo_recompute_cost_price.rst
|
||||
--- a/trytond/trytond/modules/product_cost_fifo/tests/scenario_product_cost_fifo_recompute_cost_price.rst
|
||||
+++ b/trytond/trytond/modules/product_cost_fifo/tests/scenario_product_cost_fifo_recompute_cost_price.rst
|
||||
@@ -45,6 +45,7 @@ Get stock locations::
|
||||
>>> supplier_loc, = Location.find([('code', '=', 'SUP')])
|
||||
>>> storage_loc, = Location.find([('code', '=', 'STO')])
|
||||
|
@ -289,8 +327,8 @@ index f8b952f..d4f906d 100644
|
|||
+ Decimal('100.0000')
|
||||
diff --git a/tryton.cfg b/tryton.cfg
|
||||
index dbe44d2..529bcc8 100644
|
||||
--- a/tryton.cfg
|
||||
+++ b/tryton.cfg
|
||||
--- a/trytond/trytond/modules/product_cost_fifo/tryton.cfg
|
||||
+++ b/trytond/trytond/modules/product_cost_fifo/tryton.cfg
|
||||
@@ -6,3 +6,4 @@ depends:
|
||||
stock
|
||||
xml:
|
||||
|
@ -298,15 +336,16 @@ index dbe44d2..529bcc8 100644
|
|||
+ configuration.xml
|
||||
diff --git a/view/configuration_form.xml b/view/configuration_form.xml
|
||||
new file mode 100644
|
||||
index 0000000..46c5ac5
|
||||
index 0000000..b6a45ed
|
||||
--- /dev/null
|
||||
+++ b/view/configuration_form.xml
|
||||
@@ -0,0 +1,8 @@
|
||||
+++ b/trytond/trytond/modules/product_cost_fifo/view/configuration_form.xml
|
||||
@@ -0,0 +1,9 @@
|
||||
+<?xml version="1.0"?>
|
||||
+<!-- The COPYRIGHT file at the top level of this repository contains the full
|
||||
+ copyright notices and license terms. -->
|
||||
+<data>
|
||||
+ <xpath expr="/form/" position="inside">
|
||||
+ <field name="exclude_locations" colspan="4"/>
|
||||
+ <xpath expr="/form/field[@name='shipment_internal_transit']" position="after">
|
||||
+ <label name="exclude_location"/>
|
||||
+ <field name="exclude_location"/>
|
||||
+ </xpath>
|
||||
+</data>
|
||||
|
|
Loading…
Reference in New Issue