Add module sale_order_route

This commit is contained in:
Alexis de Lattre
2019-07-30 09:31:10 +02:00
parent 7e0c438ae8
commit c57d2a0564
5 changed files with 71 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,22 @@
# Copyright 2019 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Sale Order Route',
'version': '12.0.1.0.0',
'category': 'Sales',
'license': 'AGPL-3',
'summary': 'Set route on sale order',
'description': """
This small module adds the possibility to set a route on a sale order. Upon sale order confirmation, the route will be copied to all the sale order lines.
This module has been written by Alexis de Lattre from Akretion
<alexis.delattre@akretion.com>.
""",
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['sale_stock'],
'data': ['views/sale_order.xml'],
'installable': True,
}

View File

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

View File

@@ -0,0 +1,22 @@
# Copyright 2019 Akretion France (http://www.akretion.com/)
# @author: Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import fields, models
class SaleOrder(models.Model):
_inherit = 'sale.order'
route_id = fields.Many2one(
'stock.location.route', string='Route',
ondelete='restrict', readonly=True,
states={'draft': [('readonly', False)], 'sent': [('readonly', False)]},
domain=[('sale_selectable', '=', True)])
def _action_confirm(self):
for order in self.filtered(lambda o: o.route_id):
order.order_line.filtered(
lambda l: l.product_id.type in ('product', 'consu')).write(
{'route_id': order.route_id.id})
super(SaleOrder, self)._action_confirm()

View File

@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2019 Akretion France (http://www.akretion.com/)
@author: Alexis de Lattre <alexis.delattre@akretion.com>
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<odoo>
<record id="view_order_form_inherit_sale_stock" model="ir.ui.view">
<field name="name">sale.order.route.form</field>
<field name="model">sale.order</field>
<field name="inherit_id" ref="sale_stock.view_order_form_inherit_sale_stock"/>
<field name="arch" type="xml">
<field name="partner_shipping_id" position="after">
<field name="route_id" options="{'no_create_edit': True}"/>
</field>
</field>
</record>
</odoo>