[MIG] sale_order_route to v14

This commit is contained in:
Alexis de Lattre
2021-08-26 23:18:37 +02:00
parent 75e3463a76
commit b05abba064
5 changed files with 12 additions and 16 deletions

View File

@@ -1,3 +1 @@
# -*- coding: utf-8 -*-
from . import models from . import models

View File

@@ -1,10 +1,10 @@
# Copyright 2019 Akretion France (http://www.akretion.com/) # Copyright 2019-2021 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com> # @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{ {
'name': 'Sale Order Route', 'name': 'Sale Order Route',
'version': '12.0.1.0.0', 'version': '14.0.1.0.0',
'category': 'Sales', 'category': 'Sales',
'license': 'AGPL-3', 'license': 'AGPL-3',
'summary': 'Set route on sale order', 'summary': 'Set route on sale order',
@@ -18,5 +18,5 @@ This module has been written by Alexis de Lattre from Akretion
'website': 'http://www.akretion.com', 'website': 'http://www.akretion.com',
'depends': ['sale_stock'], 'depends': ['sale_stock'],
'data': ['views/sale_order.xml'], 'data': ['views/sale_order.xml'],
'installable': False, 'installable': True,
} }

View File

@@ -1,3 +1 @@
# -*- coding: utf-8 -*-
from . import sale_order from . import sale_order

View File

@@ -1,4 +1,4 @@
# Copyright 2019 Akretion France (http://www.akretion.com/) # Copyright 2019-2021 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com> # @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
@@ -10,17 +10,17 @@ class SaleOrder(models.Model):
route_id = fields.Many2one( route_id = fields.Many2one(
'stock.location.route', string='Route', 'stock.location.route', string='Route',
ondelete='restrict', readonly=True, track_visibility='onchange', ondelete='restrict', readonly=True, tracking=True,
states={'draft': [('readonly', False)], 'sent': [('readonly', False)]}, states={'draft': [('readonly', False)], 'sent': [('readonly', False)]},
domain=[('sale_selectable', '=', True)]) check_company=True,
domain="['|', ('company_id', '=', company_id), ('company_id', '=', False), ('sale_selectable', '=', True)]")
def _action_confirm(self): def _action_confirm(self):
# Caution: take into account the scenario where # Takes into account the scenario where route_id has a value, then SO is
# route_id has a value, then SO is cancelled+back to draft, # cancelled+back to draft, then route_id = False and SO is confirmed again
# then route_id = False and SO is confirmed again
for order in self: for order in self:
vals = {'route_id': order.route_id.id or False} vals = {'route_id': order.route_id.id or False}
order.order_line.filtered( order.order_line.filtered(
lambda l: lambda l:
l.product_id.type in ('product', 'consu')).write(vals) l.product_id and l.product_id.type in ('product', 'consu')).write(vals)
super(SaleOrder, self)._action_confirm() return super()._action_confirm()

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!-- <!--
Copyright 2019 Akretion France (http://www.akretion.com/) Copyright 2019-2021 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com> @author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
--> -->