Skip to content

Commit

Permalink
[MIG] sale_recovery_moment: Migration to 16.0 (from 12.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
legalsylvain committed Jan 31, 2025
1 parent dd330b3 commit 2d52881
Show file tree
Hide file tree
Showing 15 changed files with 3 additions and 39 deletions.
2 changes: 1 addition & 1 deletion sale_recovery_moment/__manifest__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{
"name": "Sale - Recovery Moments",
"version": "12.0.1.2.2",
"version": "16.0.1.0.0",
"summary": "Manage Recovery Moments and Places for Sale Order",
"category": "Sale",
"author": "GRAP",
Expand Down
2 changes: 0 additions & 2 deletions sale_recovery_moment/models/sale_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@ def create(self, vals_list):
self._set_commitment_date_from_moment_id(vals)
return super().create(vals_list)

@api.multi
def write(self, vals):
self._set_commitment_date_from_moment_id(vals)
return super().write(vals)

@api.multi
def action_confirm(self):
SaleOrderLine = self.env["sale.order.line"]
for order in self.filtered(lambda x: x.recovery_moment_id.place_id):
Expand Down
7 changes: 0 additions & 7 deletions sale_recovery_moment/models/sale_recovery_moment.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def create(self, vals_list):
vals["code"] = self.env["ir.sequence"].next_by_code("sale.recovery.moment")
return super().create(vals_list)

@api.multi
def unlink(self):
if self.filtered(lambda x: x.valid_order_qty):
raise UserError(
Expand All @@ -171,7 +170,6 @@ def unlink(self):
return super().unlink()

# Compute Section
@api.multi
def _compute_state(self):
now = datetime.now()
for moment in self:
Expand All @@ -186,7 +184,6 @@ def _compute_state(self):
else:
moment.state = "finished_recovery"

@api.multi
@api.depends(
"group_id.min_sale_date",
"group_id.max_sale_date",
Expand All @@ -208,7 +205,6 @@ def _compute_sale_date(self):
else:
moment.min_sale_date = False

@api.multi
@api.depends(
"order_ids",
"order_ids.recovery_moment_id",
Expand Down Expand Up @@ -243,7 +239,6 @@ def _compute_order_multi(self):
else:
recovery_moment.quota_description = _("No Orders")

@api.multi
@api.depends("picking_ids", "picking_ids.recovery_moment_id", "picking_ids.state")
def _compute_picking_multi(self):
# We use sudo for the following case:
Expand All @@ -263,7 +258,6 @@ def _compute_picking_multi(self):
)
)

@api.multi
@api.depends("code", "min_recovery_date", "place_id", "group_id.short_name")
def _compute_name(self):
for moment in self.filtered(lambda x: x.group_id):
Expand Down Expand Up @@ -319,7 +313,6 @@ def _search_state(self, operator, operand):
return [("id", "in", [x[0] for x in res])]

# Constraint Section
@api.multi
@api.constrains("min_recovery_date", "max_recovery_date")
def _check_recovery_dates(self):
for moment in self:
Expand Down
12 changes: 2 additions & 10 deletions sale_recovery_moment/models/sale_recovery_moment_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from odoo.exceptions import ValidationError
from odoo.exceptions import Warning as UserError

import odoo.addons.decimal_precision as dp


class SaleRecoveryMomentGroup(models.Model):
Expand Down Expand Up @@ -95,15 +94,15 @@ class SaleRecoveryMomentGroup(models.Model):
compute="_compute_total_multi",
multi="total",
store=True,
digits=dp.get_precision("Account"),
digits="Account",
string="Total (VAT Excluded)",
)

incl_total = fields.Float(
compute="_compute_total_multi",
multi="total",
store=True,
digits=dp.get_precision("Account"),
digits="Account",
string="Total (VAT Included)",
)

Expand All @@ -129,7 +128,6 @@ def create(self, vals_list):
return super().create(vals_list)

# Compute Section
@api.multi
@api.depends("moment_ids.min_recovery_date", "moment_ids.max_recovery_date")
def _compute_recovery_date(self):
for moment_group in self:
Expand All @@ -142,7 +140,6 @@ def _compute_recovery_date(self):
[x.max_recovery_date for x in moments]
)

@api.multi
@api.depends("moment_ids.order_qty", "moment_ids.valid_order_qty")
def _compute_order_multi(self):
for moment_group in self:
Expand All @@ -151,7 +148,6 @@ def _compute_order_multi(self):
moment_group.mapped("moment_ids.valid_order_qty")
)

@api.multi
@api.depends("moment_ids.picking_qty", "moment_ids.valid_picking_qty")
def _compute_picking_multi(self):
for moment_group in self:
Expand All @@ -162,7 +158,6 @@ def _compute_picking_multi(self):
moment_group.mapped("moment_ids.valid_picking_qty")
)

@api.multi
@api.depends("valid_order_qty")
def _compute_total_multi(self):
for moment_group in self:
Expand All @@ -172,13 +167,11 @@ def _compute_total_multi(self):
moment_group.excl_total = sum(orders.mapped("amount_untaxed"))
moment_group.incl_total = sum(orders.mapped("amount_total"))

@api.multi
@api.depends("code", "short_name")
def _compute_name(self):
for moment_group in self:
moment_group.name = f"{moment_group.code} - {moment_group.short_name}"

@api.multi
def _compute_state(self):
now = datetime.now()
for moment_group in self:
Expand Down Expand Up @@ -235,7 +228,6 @@ def _search_state(self, operator, operand):
return [("id", "in", [x[0] for x in res])]

# Constraint Section
@api.multi
@api.constrains("min_sale_date", "max_sale_date")
def _check_sale_dates(self):
for moment_group in self:
Expand Down
1 change: 0 additions & 1 deletion sale_recovery_moment/models/sale_recovery_place.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def _default_company_id(self):
)

# Compute Section
@api.multi
@api.depends("name", "street", "street2", "zip", "city", "state_id", "country_id")
def _compute_complete_name(self):
for place in self:
Expand Down
1 change: 0 additions & 1 deletion sale_recovery_moment/models/stock_picking.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class StockPicking(models.Model):
readonly=True,
)

@api.multi
def _compute_print_summary_extra_info(self):
super()._compute_print_summary_extra_info()
for picking in self.filtered(lambda x: x.recovery_moment_id):
Expand Down
4 changes: 0 additions & 4 deletions sale_recovery_moment/views/view_sale_order.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<record id="action_recovery_moment_2_sale_order" model="ir.actions.act_window">
<field name="name">Sale Orders</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,graph</field>
<field name="context">{'search_default_recovery_moment_id': active_id}</field>
</record>

<record id="action_recovery_moment_2_sale_order_valid" model="ir.actions.act_window">
<field name="name">Valid Sale Orders</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,graph</field>
<field name="domain">[('state', 'not in', ('draft', 'sent', 'cancel'))]</field>
<field name="context">{'search_default_recovery_moment_id': active_id}</field>
Expand All @@ -50,15 +48,13 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<record id="action_recovery_moment_group_2_sale_order" model="ir.actions.act_window">
<field name="name">Sale Orders</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,graph</field>
<field name="context">{'search_default_recovery_group_id': active_id}</field>
</record>

<record id="action_recovery_moment_group_2_sale_order_valid" model="ir.actions.act_window">
<field name="name">Valid Sale Orders</field>
<field name="res_model">sale.order</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,graph</field>
<field name="domain">[('state', 'not in', ('draft', 'sent', 'cancel'))]</field>
<field name="context">{'search_default_recovery_group_id': active_id}</field>
Expand Down
1 change: 0 additions & 1 deletion sale_recovery_moment/views/view_sale_recovery_moment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<record id="action_sale_recovery_moment" model="ir.actions.act_window">
<field name="name">Recovery Moments</field>
<field name="res_model">sale.recovery.moment</field>
<field name="view_type">form</field>
<field name="view_mode">calendar,tree,form</field>
<field name="context">{'search_default_not_finished':1}</field>
</record>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<record id="action_sale_recovery_moment_group" model="ir.actions.act_window">
<field name="name">Recovery Moment Groups</field>
<field name="res_model">sale.recovery.moment.group</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="context">{'search_default_not_finished':1}</field>
</record>
Expand Down
1 change: 0 additions & 1 deletion sale_recovery_moment/views/view_sale_recovery_place.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<record id="action_sale_recovery_place" model="ir.actions.act_window">
<field name="name">Recovery Places</field>
<field name="res_model">sale.recovery.place</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
</record>

Expand Down
4 changes: 0 additions & 4 deletions sale_recovery_moment/views/view_stock_picking.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<record id="action_recovery_moment_group_2_stock_picking" model="ir.actions.act_window">
<field name="name">Delivery Orders</field>
<field name="res_model">stock.picking</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,graph</field>
<field name="context">{'search_default_recovery_group_id': active_id}</field>
<field name="search_view_id" ref="view_stock_picking_search"/>
Expand All @@ -52,7 +51,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<record id="action_recovery_moment_group_2_stock_picking_valid" model="ir.actions.act_window">
<field name="name">Valid Delivery Orders</field>
<field name="res_model">stock.picking</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,graph</field>
<field name="domain">[('state', 'not in', ('draft', 'cancel'))]</field>
<field name="context">{'search_default_recovery_group_id': active_id}</field>
Expand All @@ -63,7 +61,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<record id="action_recovery_moment_2_stock_picking" model="ir.actions.act_window">
<field name="name">Delivery Orders</field>
<field name="res_model">stock.picking</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,graph</field>
<field name="context">{'search_default_recovery_moment_id': active_id}</field>
<field name="search_view_id" ref="view_stock_picking_search"/>
Expand All @@ -73,7 +70,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<record id="action_recovery_moment_2_stock_picking_valid" model="ir.actions.act_window">
<field name="name">Valid Delivery Orders</field>
<field name="res_model">stock.picking</field>
<field name="view_type">form</field>
<field name="view_mode">tree,form,graph</field>
<field name="domain">[('state', 'not in', ('draft', 'cancel'))]</field>
<field name="context">{'search_default_recovery_moment_id': active_id}</field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ def _default_group_ids(self):
return self.env.context.get("active_ids", [])

# View Sections
@api.multi
def duplicate_groups(self):
self.ensure_one()
SaleRecoveryMoment = self.env["sale.recovery.moment"]
Expand Down Expand Up @@ -115,7 +114,6 @@ def onchange_day_delay(self):
self.next_min_sale_date = False
self.next_max_sale_date = False

@api.multi
def _prepare_group_vals(self, old_group):
return {
"short_name": _("%s (Copy)") % (old_group.short_name),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def _default_moment_ids(self):
return self.env.context.get("active_ids", [])

# View Sections
@api.multi
def duplicate_moments(self):
self.ensure_one()
SaleRecoveryMoment = self.env["sale.recovery.moment"]
Expand Down Expand Up @@ -78,7 +77,6 @@ def duplicate_moments(self):
action_data["context"] = False
return action_data

@api.multi
def _prepare_moment_vals(self, old_moment):
return {
"specific_min_sale_date": old_moment.specific_min_sale_date
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<record id="action_recovery_moment_group_wizard_duplicate" model="ir.actions.act_window">
<field name="name">Duplicate Recovery Moment Groups</field>
<field name="res_model">sale.recovery.moment.group.wizard.duplicate</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="binding_model_id" ref="sale_recovery_moment.model_sale_recovery_moment_group"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
<record id="action_recovery_moment_wizard_duplicate" model="ir.actions.act_window">
<field name="name">Duplicate Recovery Moment Moments</field>
<field name="res_model">sale.recovery.moment.wizard.duplicate</field>
<field name="view_type">form</field>
<field name="view_mode">form</field>
<field name="target">new</field>
<field name="binding_model_id" ref="sale_recovery_moment.model_sale_recovery_moment"/>
Expand Down

0 comments on commit 2d52881

Please sign in to comment.