[MIG] : Migration to 13.0

This commit is contained in:
Jordi Ballester Alomar
2020-10-28 06:46:09 +01:00
committed by Lois Rilo
parent 59280b39e1
commit f9eaaa00dd
3 changed files with 17 additions and 16 deletions

View File

@@ -5,7 +5,7 @@
"name": "Stock Pull List",
"summary": "The pull list checks the stock situation and calculates "
"needed quantities.",
"version": "12.0.1.0.1",
"version": "13.0.1.0.0",
"license": "LGPL-3",
"website": "https://github.com/OCA/stock-logistics-warehouse",
"author": "ForgeFlow, " "Odoo Community Association (OCA)",

View File

@@ -92,8 +92,8 @@ class PullListWizard(models.TransientModel):
qty_needed = max(demand_qty - qty_available - supply_qty, 0.0)
qty_assigned[product] = prev + qty_assigned_now
return {
"product_id": product,
"location_id": location,
"product_id": product.id if product else False,
"location_id": location.id if location else False,
"date_expected": date_expected,
"stock_rule_id": rule.id if rule else False,
"raw_demand_qty": demand_qty,
@@ -250,10 +250,7 @@ class PullListWizard(models.TransientModel):
lines_obj = self.env["stock.pull.list.wizard.line"]
errors = []
proc_groups = []
# User requesting the procurement is passed by context to be able to
# update final MO, PO or trasfer with that information.
# TODO: migration to v13: requested_uid is not needed.
pg_obj = self.env["procurement.group"].with_context(requested_uid=self.env.user)
pg_obj = self.env["procurement.group"]
grouping_keys = self._get_procurement_group_keys()
fields = self._get_fields_for_keys()
for gk in grouping_keys:
@@ -266,6 +263,7 @@ class PullListWizard(models.TransientModel):
continue
group = pg_obj.create(self._prepare_proc_group_values())
proc_groups.append(group.id)
procurements = []
for line in lines.filtered(lambda l: l.selected):
n += 1
if 0 < self.max_lines < n:
@@ -274,20 +272,25 @@ class PullListWizard(models.TransientModel):
proc_groups.append(group.id)
values = self._prepare_procurement_values(line.date_expected, group)
try:
pg_obj.run(
procurements.append(
pg_obj.Procurement(
line.product_id,
line.needed_qty,
line.product_id.uom_id,
line.location_id,
"Pull List %s" % self.id,
"Pull List %s" % self.id,
self.env.user.company_id,
values,
)
except UserError as error:
errors.append(error.name)
if errors:
raise UserError("\n".join(errors))
)
# Run procurements
try:
pg_obj.run(procurements)
except UserError as error:
errors.append(error.name)
if errors:
raise UserError("\n".join(errors))
res = {
"name": _("Generated Procurement Groups"),
"src_model": "stock.pull.list.wizard",

View File

@@ -1,4 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2020 ForgeFlow S.L.
License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl). -->
<odoo>
@@ -116,10 +115,9 @@
<act_window
name="Generate Pull List"
res_model="stock.pull.list.wizard"
src_model="stock.pull.list.wizard"
binding_model="stock.pull.list.wizard"
view_mode="form"
target="new"
key2="client_action_multi"
id="action_stock_pull_list_wizard"
/>
<menuitem