Skip to content

Commit

Permalink
[MIG] stock_secondary_unit: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rov-adhoc committed Jan 10, 2025
1 parent 14db8c7 commit 6ad41fc
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 48 deletions.
2 changes: 1 addition & 1 deletion stock_secondary_unit/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion stock_secondary_unit/report/report_deliveryslip.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</td>
</xpath>
<xpath
expr='//table[@t-if="o.move_line_ids and o.state==&apos;done&apos;"]/thead/tr/th'
expr='//table[@t-elif="o.move_line_ids and o.state==&apos;done&apos;"]/thead/tr/th'
position="after"
>
<th>
Expand Down
25 changes: 12 additions & 13 deletions stock_secondary_unit/tests/test_stock_secondary_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,19 +179,18 @@ def test_picking_secondary_unit(self):

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]
Expand Down
18 changes: 12 additions & 6 deletions stock_secondary_unit/views/product_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
36 changes: 30 additions & 6 deletions stock_secondary_unit/views/stock_move_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -20,7 +20,7 @@
domain="product_id and ['|', ('product_id', '=', product_id),
'&amp;', ('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"
Expand All @@ -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"
Expand All @@ -49,12 +49,36 @@
domain="product_id and ['|', ('product_id', '=', product_id),
'&amp;', ('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"
/>
</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),
'&amp;', ('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>
24 changes: 3 additions & 21 deletions stock_secondary_unit/views/stock_picking_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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), '&amp;', '&amp;', ('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"
/>
Expand All @@ -23,30 +24,11 @@
'&amp;', ('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), '&amp;', '&amp;', ('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),
'&amp;', ('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>

0 comments on commit 6ad41fc

Please sign in to comment.