Skip to content

Commit

Permalink
[MIG] sale_elaboration: Migration to 17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
peluko00 committed Aug 20, 2024
1 parent d60116e commit 52fec70
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 64 deletions.
3 changes: 3 additions & 0 deletions sale_elaboration/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ Contributors

- Eduardo de Miguel (`Moduon <https://www.moduon.team/>`__)
- Jairo Llopis (`Moduon <https://www.moduon.team/>`__)
- `APSL-Nagarro <https://apsl.tech>`__:

- Antoni Marroig <[email protected]>

Maintainers
-----------
Expand Down
3 changes: 2 additions & 1 deletion sale_elaboration/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{
"name": "Sale Elaboration",
"summary": "Set an elaboration for any sale line",
"version": "16.0.1.7.0",
"version": "17.0.1.0.0",
"development_status": "Production/Stable",
"category": "Sale",
"website": "https://github.com/OCA/sale-workflow",
Expand All @@ -23,6 +23,7 @@
"views/sale_elaboration_report_views.xml",
"views/stock_move_line_views.xml",
"views/stock_picking_views.xml",
"views/stock_move_views.xml",
"reports/report_base.xml",
"reports/report_deliveryslip.xml",
"reports/report_picking_operations.xml",
Expand Down
6 changes: 3 additions & 3 deletions sale_elaboration/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).


def pre_init_hook(cr):
def pre_init_hook(env):
"""Create computed columns if not exists when the module is instelled"""
cr.execute(
env.cr.execute(
"""
ALTER TABLE sale_order_line
ADD COLUMN IF NOT EXISTS is_elaboration BOOLEAN;
"""
)
cr.execute(
env.cr.execute(
"""
ALTER TABLE sale_order_line ADD COLUMN IF NOT EXISTS elaboration_note VARCHAR;
"""
Expand Down
3 changes: 1 addition & 2 deletions sale_elaboration/models/product_elaboration.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ class Elaboration(models.Model):
string="Routes",
domain=[("sale_selectable", "=", True)],
ondelete="restrict",
check_company=True,
)
profile_ids = fields.Many2many(
comodel_name="product.elaboration.profile",
Expand All @@ -52,4 +51,4 @@ def name_search(self, name, args=None, operator="ilike", limit=100):
recs = self.search([("code", "=ilike", name)] + args, limit=limit)
if not recs:
recs = self.search([("name", operator, name)] + args, limit=limit)
return recs.name_get()
return [(record.id, record.display_name) for record in recs.sudo()]
2 changes: 1 addition & 1 deletion sale_elaboration/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ def _action_done(self):
)
for line in elaboration_lines:
for product in line.sale_line_id.elaboration_ids.product_id:
pick.sale_id._create_elaboration_line(product, line.quantity_done)
pick.sale_id._create_elaboration_line(product, line.product_uom_qty)
return res
2 changes: 2 additions & 0 deletions sale_elaboration/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@
- Ernesto Tejeda
- Eduardo de Miguel ([Moduon](https://www.moduon.team/))
- Jairo Llopis ([Moduon](https://www.moduon.team/))
- [APSL-Nagarro](https://apsl.tech):
- Antoni Marroig \<<[email protected]>\>
4 changes: 4 additions & 0 deletions sale_elaboration/static/description/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ <h2><a class="toc-backref" href="#toc-entry-6">Contributors</a></h2>
</li>
<li>Eduardo de Miguel (<a class="reference external" href="https://www.moduon.team/">Moduon</a>)</li>
<li>Jairo Llopis (<a class="reference external" href="https://www.moduon.team/">Moduon</a>)</li>
<li><a class="reference external" href="https://apsl.tech">APSL-Nagarro</a>:<ul>
<li>Antoni Marroig &lt;<a class="reference external" href="mailto:amarroig&#64;apsl.net">amarroig&#64;apsl.net</a>&gt;</li>
</ul>
</li>
</ul>
</div>
<div class="section" id="maintainers">
Expand Down
8 changes: 4 additions & 4 deletions sale_elaboration/tests/test_sale_elaboration.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def test_sale_elaboration_doesnt_change(self):

def test_sale_elaboration(self):
self.order.action_confirm()
self.order.picking_ids.move_ids.quantity_done = 10.0
self.order.picking_ids.move_ids.product_uom_qty = 10.0
self.order.picking_ids._action_done()
elaboration_lines = self.order.order_line.filtered("is_elaboration")
self.assertEqual(len(elaboration_lines), 1)
Expand All @@ -110,7 +110,7 @@ def test_sale_elaboration_multi(self):
}
)
self.order.action_confirm()
self.order.picking_ids.move_ids.quantity_done = 10.0
self.order.picking_ids.move_ids.product_uom_qty = 10.0
self.order.picking_ids._action_done()
elaboration_lines = self.order.order_line.filtered("is_elaboration")
self.assertEqual(len(elaboration_lines), 1)
Expand Down Expand Up @@ -162,9 +162,9 @@ def test_multi_elaboration_per_line(self):
self.order.action_confirm()
move_ids = self.order.picking_ids.move_ids
move_line_a = move_ids.filtered(lambda r: r.product_id == self.product)
move_line_a.quantity_done = 10.0
move_line_a.product_uom_qty = 10.0
move_line_b = move_ids.filtered(lambda r: r.product_id == product2)
move_line_b.quantity_done = 1.0
move_line_b.product_uom_qty = 1.0
self.order.picking_ids._action_done()
elaboration_lines = self.order.order_line.filtered("is_elaboration")
self.assertEqual(len(elaboration_lines), 2)
Expand Down
7 changes: 2 additions & 5 deletions sale_elaboration/views/product_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
<field name="inherit_id" ref="product.product_template_only_form_view" />
<field name="arch" type="xml">
<field name='default_code' position="after">
<field
name="is_elaboration"
attrs="{'invisible': [('type', '!=', 'service')]}"
/>
<field name="is_elaboration" invisible="type != 'service'" />
</field>
</field>
</record>
Expand All @@ -23,7 +20,7 @@
<group name="elboration" string="Elaborations">
<field
name="elaboration_profile_id"
attrs="{'invisible':[('product_variant_count', '&gt;', 1), ('is_product_variant', '=', False)]}"
invisible="product_variant_count > 1 and not is_product_variant"
/>
</group>
</xpath>
Expand Down
32 changes: 9 additions & 23 deletions sale_elaboration/views/res_config_settings_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,21 @@
<field name="model">res.config.settings</field>
<field name="inherit_id" ref="stock.res_config_settings_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[@id='group_lot_on_delivery_slip']" position="after">
<div
class="col-12 col-lg-6 o_setting_box"
<xpath expr="//setting[@id='group_lot_on_delivery_slip']" position="after">
<setting
help="Elaboration notes will appear on the delivery slip"
id="group_elaboration_note_on_delivery_slip"
>
<div class="o_setting_left_pane">
<field name="group_elaboration_note_on_delivery_slip" />
</div>
<div class="o_setting_right_pane">
<label for="group_elaboration_note_on_delivery_slip" />
<div class="text-muted">
Elaboration notes will appear on the delivery slip
</div>
</div>
</div>
<div
class="col-12 col-lg-6 o_setting_box"
</setting>
<setting
help="Elaboration notes will appear on the picking operations report"
id="group_elaboration_note_on_picking_operations"
>
<div class="o_setting_left_pane">
<field name="group_elaboration_note_on_picking_operations" />
</div>
<div class="o_setting_right_pane">
<label for="group_elaboration_note_on_picking_operations" />
<div class="text-muted">
Elaboration notes will appear on the picking operations report
</div>
</div>
</div>
<field name="group_elaboration_note_on_picking_operations" />
<label for="group_elaboration_note_on_picking_operations" />
</setting>
</xpath>
</field>
</record>
Expand Down
2 changes: 1 addition & 1 deletion sale_elaboration/views/sale_elaboration_profile_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
invisible="active"
/>
<field name="active" invisible="1" />
<group>
Expand Down
2 changes: 1 addition & 1 deletion sale_elaboration/views/sale_elaboration_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
name="web_ribbon"
title="Archived"
bg_color="bg-danger"
attrs="{'invisible': [('active', '=', True)]}"
invisible="active"
/>
<field name="active" invisible="1" />
<group>
Expand Down
12 changes: 6 additions & 6 deletions sale_elaboration/views/sale_order_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,36 +14,36 @@
<field
name="elaboration_ids"
widget="many2many_tags"
attrs="{'readonly': ['|', ('product_updatable', '=', False), ('parent.state', 'in', ('done', 'cancel'))]}"
readonly="not product_updatable or parent.state in ['done', 'cancel']"
domain="elaboration_profile_id and [('profile_ids', 'in', [elaboration_profile_id])] or []"
/>
<field
name="elaboration_note"
attrs="{'readonly': ['|', ('product_updatable', '=', False), ('parent.state', 'in', ('done', 'cancel'))]}"
readonly="not product_updatable or parent.state in ['done', 'cancel']"
/>
<field
name="elaboration_price_unit"
readonly="1"
widget="monetary"
attrs="{'invisible': [('elaboration_ids', '=', [])]}"
invisible="not elaboration_ids"
/>
</group>
</xpath>
<xpath
expr="//field[@name='order_line']/tree//field[@name='price_unit']"
position="after"
>
<field name="elaboration_profile_id" invisible="1" />
<field name="elaboration_profile_id" column_invisible="1" />
<field
name="elaboration_ids"
widget="many2many_tags"
attrs="{'readonly': ['|', ('product_updatable', '=', False), ('parent.state', 'in', ('done', 'cancel'))]}"
readonly="not product_updatable or parent.state in ['done', 'cancel']"
domain="elaboration_profile_id and [('profile_ids', 'in', [elaboration_profile_id])] or []"
optional="show"
/>
<field
name="elaboration_note"
attrs="{'readonly': ['|', ('product_updatable', '=', False), ('parent.state', 'in', ('done', 'cancel'))]}"
readonly="not product_updatable or parent.state in ['done', 'cancel']"
optional="show"
/>
<field
Expand Down
25 changes: 25 additions & 0 deletions sale_elaboration/views/stock_move_views.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2023 Tecnativa - Sergio Teruel
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="view_stock_move_operations_sale_operation" model="ir.ui.view">
<field name="name">stock.move.operation.sale</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" readonly="1" />
<field
name="elaboration_ids"
widget="many2many_tags"
options="{'no_create': True}"
readonly="not is_initial_demand_editable"
/>
<field
name="elaboration_note"
readonly="not is_initial_demand_editable"
/>
</xpath>
</field>
</record>
</odoo>
20 changes: 3 additions & 17 deletions sale_elaboration/views/stock_picking_views.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,20 @@
expr="//field[@name='move_ids_without_package']/tree/field[@name='product_uom']"
position="after"
>
<field name="show_operations" invisible="1" readonly="1" />
<field
name="elaboration_ids"
widget="many2many_tags"
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"
optional="show"
/>
<field
name="elaboration_note"
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"
optional="show"
/>
</xpath>
<xpath
expr="//field[@name='move_ids_without_package']/form//field[@name='product_uom']"
position="after"
>
<field
name="elaboration_ids"
widget="many2many_tags"
options="{'no_create': True}"
attrs="{'invisible': [('parent.immediate_transfer', '=', True)], 'readonly': [('is_initial_demand_editable', '=', False)]}"
/>
<field
name="elaboration_note"
attrs="{'invisible': [('parent.immediate_transfer', '=', True)], 'readonly': [('is_initial_demand_editable', '=', False)]}"
/>
</xpath>
</field>
</record>
</odoo>

0 comments on commit 52fec70

Please sign in to comment.