mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
[MIG] stock_secondary_unit: Migration to 17.0
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
{
|
||||
"name": "Stock Secondary Unit",
|
||||
"summary": "Get product quantities in a secondary unit",
|
||||
"version": "16.0.1.1.2",
|
||||
"version": "17.0.1.0.0",
|
||||
"development_status": "Production/Stable",
|
||||
"category": "stock",
|
||||
"website": "https://github.com/OCA/stock-logistics-warehouse",
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
</td>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr='//table[@t-if="o.move_line_ids and o.state=='done'"]/thead/tr/th'
|
||||
expr='//table[@t-elif="o.move_line_ids and o.state=='done'"]/thead/tr/th'
|
||||
position="after"
|
||||
>
|
||||
<th>
|
||||
|
||||
@@ -179,19 +179,18 @@ class TestProductSecondaryUnit(TransactionCase):
|
||||
|
||||
picking = picking_form.save()
|
||||
picking.action_confirm()
|
||||
with Form(picking) as picking_form:
|
||||
# Test detail operations
|
||||
with picking_form.move_line_ids_without_package.new() as move:
|
||||
move.product_id = product
|
||||
move.secondary_uom_qty = 1
|
||||
move.secondary_uom_id = product.product_tmpl_id.secondary_uom_ids[0]
|
||||
self.assertEqual(move.qty_done, 0.5)
|
||||
move.secondary_uom_qty = 2
|
||||
self.assertEqual(move.qty_done, 1)
|
||||
move.secondary_uom_id = product.product_tmpl_id.secondary_uom_ids[1]
|
||||
self.assertEqual(move.qty_done, 1.8)
|
||||
move.qty_done = 5
|
||||
self.assertAlmostEqual(move.secondary_uom_qty, 5.56, 2)
|
||||
stock_move_line = picking.move_line_ids_without_package
|
||||
stock_move_line.product_id = product
|
||||
stock_move_line.product_uom_id = stock_move_line.product_id.uom_id.id
|
||||
stock_move_line.secondary_uom_qty = 1
|
||||
stock_move_line.secondary_uom_id = product.product_tmpl_id.secondary_uom_ids[0]
|
||||
self.assertEqual(stock_move_line.qty_done, 0.5)
|
||||
stock_move_line.secondary_uom_qty = 2
|
||||
self.assertEqual(stock_move_line.qty_done, 1)
|
||||
stock_move_line.secondary_uom_id = product.product_tmpl_id.secondary_uom_ids[1]
|
||||
self.assertEqual(stock_move_line.qty_done, 1.8)
|
||||
stock_move_line.qty_done = 5
|
||||
self.assertAlmostEqual(stock_move_line.secondary_uom_qty, 5.56, 2)
|
||||
|
||||
def test_secondary_unit_merge_move_diff_uom(self):
|
||||
product = self.product_template.product_variant_ids[0]
|
||||
|
||||
@@ -24,11 +24,14 @@
|
||||
ref="stock.product_template_form_view_procurement_button"
|
||||
/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='action_open_quants']" position="after">
|
||||
<xpath
|
||||
expr="//button[@name='action_view_stock_move_lines']"
|
||||
position="before"
|
||||
>
|
||||
<button
|
||||
type="object"
|
||||
name="action_open_quants"
|
||||
attrs="{'invisible':[('type', '!=', 'product')]}"
|
||||
name="action_update_quantity_on_hand"
|
||||
invisible="type != 'product'"
|
||||
class="oe_stat_button"
|
||||
icon="fa-building-o"
|
||||
groups="stock.group_stock_user"
|
||||
@@ -53,11 +56,14 @@
|
||||
<field name="model">product.product</field>
|
||||
<field name="inherit_id" ref="stock.product_form_view_procurement_button" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='action_open_quants']" position="after">
|
||||
<xpath
|
||||
expr="//button[@name='action_update_quantity_on_hand']"
|
||||
position="after"
|
||||
>
|
||||
<button
|
||||
type="object"
|
||||
name="action_open_quants"
|
||||
attrs="{'invisible':[('type', '!=', 'product')]}"
|
||||
name="action_update_quantity_on_hand"
|
||||
invisible="type != 'product'"
|
||||
class="oe_stat_button"
|
||||
icon="fa-building-o"
|
||||
groups="stock.group_stock_user"
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
<field name="model">stock.move.line</field>
|
||||
<field name="inherit_id" ref="stock.view_stock_move_line_operation_tree" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="reserved_uom_qty" position="before">
|
||||
<field name="quantity" position="before">
|
||||
<field
|
||||
name="secondary_uom_qty"
|
||||
attrs="{'readonly': [('state', 'in', ('done', 'cancel')), ('is_locked', '=', True)]}"
|
||||
readonly="state in ['done', 'cancel'] and is_locked"
|
||||
force_save="1"
|
||||
groups="uom.group_uom"
|
||||
optional="show"
|
||||
@@ -20,7 +20,7 @@
|
||||
domain="product_id and ['|', ('product_id', '=', product_id),
|
||||
'&', ('product_tmpl_id.product_variant_ids', 'in', [product_id]),
|
||||
('product_id', '=', False)] or [(0, '=', 1)]"
|
||||
attrs="{'readonly': [('state', '!=', 'draft'), ('id', '!=', False)]}"
|
||||
readonly="state != 'draft' and id"
|
||||
options="{'no_create': True}"
|
||||
groups="uom.group_uom"
|
||||
optional="show"
|
||||
@@ -36,10 +36,10 @@
|
||||
ref="stock.view_stock_move_line_detailed_operation_tree"
|
||||
/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="reserved_uom_qty" position="before">
|
||||
<field name="quantity" position="before">
|
||||
<field
|
||||
name="secondary_uom_qty"
|
||||
attrs="{'readonly': [('state', 'in', ('done', 'cancel')), ('is_locked', '=', True)]}"
|
||||
readonly="state in ['done', 'cancel'] and is_locked"
|
||||
force_save="1"
|
||||
groups="uom.group_uom"
|
||||
optional="show"
|
||||
@@ -49,7 +49,7 @@
|
||||
domain="product_id and ['|', ('product_id', '=', product_id),
|
||||
'&', ('product_tmpl_id.product_variant_ids', 'in', [product_id]),
|
||||
('product_id', '=', False)] or [(0, '=', 1)]"
|
||||
attrs="{'readonly': [('state', '!=', 'draft'), ('id', '!=', False)]}"
|
||||
readonly="state != 'draft' and id"
|
||||
options="{'no_create': True}"
|
||||
groups="uom.group_uom"
|
||||
optional="show"
|
||||
@@ -57,4 +57,28 @@
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
<record id="view_stock_move_operations" model="ir.ui.view">
|
||||
<field name="name">stock.move.operations.form.inherit</field>
|
||||
<field name="model">stock.move</field>
|
||||
<field name="inherit_id" ref="stock.view_stock_move_operations" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='product_id']" position="after">
|
||||
<field name="is_initial_demand_editable" invisible="1" />
|
||||
<field
|
||||
name="secondary_uom_qty"
|
||||
readonly="not is_initial_demand_editable"
|
||||
groups="uom.group_uom"
|
||||
/>
|
||||
<field
|
||||
name="secondary_uom_id"
|
||||
domain="product_id and ['|', ('product_id', '=', product_id),
|
||||
'&', ('product_tmpl_id.product_variant_ids', 'in', [product_id]),
|
||||
('product_id', '=', False)] or [(0, '=', 1)]"
|
||||
options="{'no_create': True}"
|
||||
readonly="not is_initial_demand_editable"
|
||||
groups="uom.group_uom"
|
||||
/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
@@ -11,9 +11,10 @@
|
||||
expr="//field[@name='move_ids_without_package']/tree/field[@name='product_uom_qty']"
|
||||
position="before"
|
||||
>
|
||||
<field name="show_operations" invisible="1" />
|
||||
<field
|
||||
name="secondary_uom_qty"
|
||||
attrs="{'column_invisible': [('parent.immediate_transfer', '=', True)], 'readonly': ['|', ('is_initial_demand_editable', '=', False), '&', '&', ('show_operations', '=', True), ('is_locked', '=', True), ('is_initial_demand_editable', '=', False)]}"
|
||||
readonly="(not is_initial_demand_editable) or (show_operations and is_locked and not is_initial_demand_editable)"
|
||||
groups="uom.group_uom"
|
||||
optional="show"
|
||||
/>
|
||||
@@ -23,30 +24,11 @@
|
||||
'&', ('product_tmpl_id.product_variant_ids', 'in', [product_id]),
|
||||
('product_id', '=', False)] or [(0, '=', 1)]"
|
||||
options="{'no_create': True}"
|
||||
attrs="{'column_invisible': [('parent.immediate_transfer', '=', True)], 'readonly': ['|', ('is_initial_demand_editable', '=', False), '&', '&', ('show_operations', '=', True), ('is_locked', '=', True), ('is_initial_demand_editable', '=', False)]}"
|
||||
readonly="(not is_initial_demand_editable) or (show_operations and is_locked and not is_initial_demand_editable)"
|
||||
groups="uom.group_uom"
|
||||
optional="show"
|
||||
/>
|
||||
</xpath>
|
||||
<xpath
|
||||
expr="//field[@name='move_ids_without_package']/form//field[@name='product_uom_qty']"
|
||||
position="before"
|
||||
>
|
||||
<field
|
||||
name="secondary_uom_qty"
|
||||
attrs="{'invisible': [('parent.immediate_transfer', '=', True)], 'readonly': [('is_initial_demand_editable', '=', False)]}"
|
||||
groups="uom.group_uom"
|
||||
/>
|
||||
<field
|
||||
name="secondary_uom_id"
|
||||
domain="product_id and ['|', ('product_id', '=', product_id),
|
||||
'&', ('product_tmpl_id.product_variant_ids', 'in', [product_id]),
|
||||
('product_id', '=', False)] or [(0, '=', 1)]"
|
||||
options="{'no_create': True}"
|
||||
attrs="{'invisible': [('parent.immediate_transfer', '=', True)], 'readonly': [('is_initial_demand_editable', '=', False)]}"
|
||||
groups="uom.group_uom"
|
||||
/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user