diff --git a/inventory.py b/inventory.py index 8ff98fb67b..4778a95441 100644 --- a/inventory.py +++ b/inventory.py @@ -209,11 +209,11 @@ class InventoryLine(ModelSQL, ModelView): uom = fields.Function(fields.Many2One('product.uom', 'UOM'), 'get_uom') unit_digits = fields.Function(fields.Integer('Unit Digits'), 'get_unit_digits') - expected_quantity = fields.Float('Expected Quantity', + expected_quantity = fields.Float('Expected Quantity', required=True, digits=(16, Eval('unit_digits', 2)), readonly=True, depends=['unit_digits']) - quantity = fields.Float('Quantity', digits=(16, Eval('unit_digits', 2)), - depends=['unit_digits']) + quantity = fields.Float('Quantity', required=True, + digits=(16, Eval('unit_digits', 2)), depends=['unit_digits']) move = fields.Many2One('stock.move', 'Move', readonly=True) inventory = fields.Many2One('stock.inventory', 'Inventory', required=True, ondelete='CASCADE') diff --git a/inventory.xml b/inventory.xml index 64f4cdc4c7..f90927a523 100644 --- a/inventory.xml +++ b/inventory.xml @@ -142,23 +142,23 @@ this repository contains the full copyright notices and license terms. --> Inventory stock.inventory - True + - True + wkf_draft Draft - True + Canceled wkf_cancel - True + Done wkf_done diff --git a/product.py b/product.py index 2588486b72..5e8b0b9d65 100644 --- a/product.py +++ b/product.py @@ -1,10 +1,11 @@ #This file is part of Tryton. The COPYRIGHT file at the top level of #this repository contains the full copyright notices and license terms. +import copy import datetime from decimal import Decimal from trytond.model import ModelView, ModelSQL, fields from trytond.wizard import Wizard, StateView, StateAction, Button -from trytond.pyson import PYSONEncoder +from trytond.pyson import PYSONEncoder, Eval, Or from trytond.transaction import Transaction from trytond.tools import safe_eval, reduce_ids from trytond.pool import Pool @@ -36,6 +37,14 @@ class Template(ModelSQL, ModelView): 'change_default_uom': 'You cannot change the default uom for '\ 'a product which is associated to stock moves.', }) + self.cost_price = copy.copy(self.cost_price) + self.cost_price.states = copy.copy(self.cost_price.states) + self.cost_price.states['required'] = Or( + self.cost_price.states.get('required', True), + Eval('type').in_(['goods', 'assets'])) + self.cost_price.depends = copy.copy(self.cost_price.depends) + self.cost_price.depends.append('type') + self._reset_columns() def write(self, ids, vals): move_obj = Pool().get('stock.move') diff --git a/shipment.xml b/shipment.xml index cc9b5c2ec8..93564a0eca 100644 --- a/shipment.xml +++ b/shipment.xml @@ -714,23 +714,23 @@ this repository contains the full copyright notices and license terms. --> Supplier Shipment stock.shipment.in - True + - True + wkf_draft Draft - True + Canceled wkf_cancel - True + Done wkf_done @@ -779,23 +779,23 @@ this repository contains the full copyright notices and license terms. --> Customer Shipment stock.shipment.out - True + - True + Draft wkf_draft - True + Canceled wkf_cancel - True + Done wkf_done @@ -977,23 +977,23 @@ this repository contains the full copyright notices and license terms. --> Internal Shipment stock.shipment.internal - True + - True + wkf_draft Draft - True + Canceled wkf_cancel - True + Done wkf_done @@ -1083,23 +1083,23 @@ this repository contains the full copyright notices and license terms. --> Customer Return Shipment stock.shipment.out.return - True + - True + wkf_draft Draft - True + Canceled wkf_cancel - True + Done wkf_done @@ -1147,23 +1147,23 @@ this repository contains the full copyright notices and license terms. --> Supplier Return Shipment stock.shipment.in.return - True + - True + wkf_draft Draft - True + Canceled wkf_cancel - True + Done wkf_done diff --git a/tests/test_stock.py b/tests/test_stock.py index 4ce7e7916c..17989034d3 100644 --- a/tests/test_stock.py +++ b/tests/test_stock.py @@ -63,6 +63,8 @@ class StockTestCase(unittest.TestCase): product_id = self.product.create({ 'name': 'Test Move.internal_quantity', 'type': 'goods', + 'list_price': Decimal(0), + 'cost_price': Decimal(0), 'category': category_id, 'cost_price_method': 'fixed', 'default_uom': kg_id, @@ -120,6 +122,8 @@ class StockTestCase(unittest.TestCase): product_id = self.product.create({ 'name': 'Test products_by_location', 'type': 'goods', + 'list_price': Decimal(0), + 'cost_price': Decimal(0), 'category': category_id, 'cost_price_method': 'fixed', 'default_uom': kg_id, @@ -333,6 +337,8 @@ class StockTestCase(unittest.TestCase): 'category': category_id, 'cost_price_method': 'fixed', 'default_uom': unit_id, + 'list_price': Decimal(0), + 'cost_price': Decimal(0), }) supplier_id, = self.location.search([('code', '=', 'SUP')]) customer_id, = self.location.search([('code', '=', 'CUS')])