Migrate to 6.0

This commit is contained in:
José Miguel Pardo Salar 2022-11-30 09:08:52 +01:00
parent 6b6eb04af9
commit 234afbec5a
6 changed files with 32 additions and 25 deletions

View File

@ -6,8 +6,6 @@ from trytond.pool import PoolMeta
from trytond.pyson import Eval
from trytond.const import OPERATORS
__all__ = ['ShipmentOut', 'Lot', 'Move']
class ShipmentOut(metaclass=PoolMeta):
__name__ = 'stock.shipment.out'
@ -40,7 +38,7 @@ class Lot(metaclass=PoolMeta):
@classmethod
def _search_domain_active(cls, domain, active_test=True):
domain = super(Lot, cls)._search_domain_active(domain, active_test)
domain = super()._search_domain_active(domain, active_test)
if not Transaction().context.get('available_test', False):
return domain
@ -72,7 +70,7 @@ class Lot(metaclass=PoolMeta):
"Return null instead of 0.0 if no locations in context"
if not Transaction().context.get('locations'):
return {}.fromkeys([l.id for l in lots], None)
return super(Lot, cls).get_quantity(lots, name)
return super().get_quantity(lots, name)
class Move(metaclass=PoolMeta):
@ -80,7 +78,7 @@ class Move(metaclass=PoolMeta):
@classmethod
def __setup__(cls):
super(Move, cls).__setup__()
super().__setup__()
cls.lot.context['locations'] = [Eval('from_location')]
if 'from_location' not in cls.lot.depends:
cls.lot.depends.append('from_location')

View File

@ -10,10 +10,10 @@ this repository contains the full copyright notices and license terms. -->
<field name="name">move_form</field>
</record>
<!-- Lot -->
<record model="ir.ui.view" id="stock_lot_view_tree">
<field name="model">stock.lot</field>
<field name="inherit" ref="stock_lot.lot_quantity_view_tree"/>
<field name="name">stock_lot_tree</field>
</record>
<record model="ir.ui.view" id="stock_lot_quantity_view_list">
<field name="model">stock.lot</field>
<field name="type">tree</field>
<field name="name">stock_lot_quantity_list</field>
</record>
</data>
</tryton>

View File

@ -36,17 +36,15 @@ Create product::
>>> ProductUom = Model.get('product.uom')
>>> ProductTemplate = Model.get('product.template')
>>> Product = Model.get('product.product')
>>> unit, = ProductUom.find([('name', '=', 'Unit')])
>>> product = Product()
>>> template = ProductTemplate()
>>> template.name = 'Product'
>>> template.default_uom = unit
>>> template.type = 'goods'
>>> template.list_price = Decimal('20')
>>> template.cost_price = Decimal('8')
>>> template.save()
>>> product.template = template
>>> product, = template.products
>>> product.cost_price = Decimal('8')
>>> product.save()
@ -67,16 +65,19 @@ Get stock locations::
>>> storage_loc, = Location.find([('code', '=', 'STO')])
Add to context locations and test_available
Add to context locations and test_available::
>>> config._context['locations'] = [storage_loc.id]
>>> config._context['available_test'] = True
Check lot with context added
Check lot with context added::
>>> lots = Lot.find([])
>>> len(lots)
0
>>> config._context['locations'] = None
>>> config._context['available_test'] = None
Create Stock Move::
@ -97,6 +98,12 @@ Create Stock Move::
>>> move.click('do')
Add to context locations and test_available::
>>> config._context['locations'] = [storage_loc.id]
>>> config._context['available_test'] = True
Check lot with context added::
>>> lots = Lot.find([])

View File

@ -3,6 +3,6 @@
copyright notices and license terms. -->
<data>
<xpath expr="/form/field[@name='lot']" position="replace_attributes">
<field name="lot" view_ids="stock_lot.lot_quantity_view_tree"/>
<field name="lot" view_ids="stock_lot_available.stock_lot_quantity_view_list"/>
</xpath>
</data>

View File

@ -0,0 +1,10 @@
<?xml version="1.0"?>
<!-- The COPYRIGHT file at the top level of
this repository contains the full copyright notices and license terms. -->
<tree>
<field name="number"/>
<field name="product"/>
<field name="quantity"/>
<field name="forecast_quantity"/>
<field name="available" tree_invisible="1"/>
</tree>

View File

@ -1,8 +0,0 @@
<?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="/tree" position="inside">
<field name="available" tree_invisible="1"/>
</xpath>
</data>