stock_usability: Add computed field is_dropship (needed to customize some reports)
This commit is contained in:
@@ -31,6 +31,7 @@ This module has been written by Alexis de Lattre from Akretion <alexis.delattre@
|
||||
'views/stock_location.xml',
|
||||
'views/stock_move.xml',
|
||||
'views/stock_picking.xml',
|
||||
'views/stock_picking_type.xml',
|
||||
'views/stock_warehouse.xml',
|
||||
'views/stock_warehouse_orderpoint.xml',
|
||||
'views/product.xml',
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from . import stock_move
|
||||
from . import stock_picking
|
||||
from . import stock_picking_type
|
||||
from . import stock_location_route
|
||||
from . import stock_warehouse_orderpoint
|
||||
from . import stock_quant
|
||||
|
||||
@@ -3,9 +3,6 @@
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from odoo import fields, models, _
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class StockPicking(models.Model):
|
||||
@@ -24,9 +21,3 @@ class StockPicking(models.Model):
|
||||
for pick in self:
|
||||
pick.message_post(body=_("Picking <b>unreserved</b>."))
|
||||
return res
|
||||
|
||||
|
||||
class StockPickingType(models.Model):
|
||||
_inherit = 'stock.picking.type'
|
||||
|
||||
name = fields.Char(translate=False)
|
||||
|
||||
27
stock_usability/models/stock_picking_type.py
Normal file
27
stock_usability/models/stock_picking_type.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# Copyright 2014-2020 Akretion (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 api, fields, models
|
||||
|
||||
|
||||
class StockPickingType(models.Model):
|
||||
_inherit = 'stock.picking.type'
|
||||
|
||||
name = fields.Char(translate=False)
|
||||
is_dropship = fields.Boolean(compute="_compute_is_dropship", store=True)
|
||||
|
||||
@api.depends("code", "warehouse_id", "default_location_src_id", "default_location_dest_id")
|
||||
def _compute_is_dropship(self):
|
||||
supplier_loc_id = self.env.ref("stock.stock_location_suppliers").id
|
||||
customer_loc_id = self.env.ref("stock.stock_location_customers").id
|
||||
for picktype in self:
|
||||
is_dropship = False
|
||||
if (
|
||||
picktype.code == 'incoming'
|
||||
and not picktype.warehouse_id
|
||||
and picktype.default_location_src_id.id == supplier_loc_id
|
||||
and picktype.default_location_dest_id.id == customer_loc_id
|
||||
):
|
||||
is_dropship = True
|
||||
picktype.is_dropship = is_dropship
|
||||
@@ -61,6 +61,10 @@
|
||||
<field name="product_id" position="after">
|
||||
<field name="product_barcode" optional="hide"/>
|
||||
</field>
|
||||
<field name="reference" position="after">
|
||||
<field name="origin" optional="hide"/>
|
||||
<field name="partner_id" optional="hide"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
22
stock_usability/views/stock_picking_type.xml
Normal file
22
stock_usability/views/stock_picking_type.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright 2023 Akretion (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_picking_type_form" model="ir.ui.view">
|
||||
<field name="model">stock.picking.type</field>
|
||||
<field name="inherit_id" ref="stock.view_picking_type_form" />
|
||||
<field name="arch" type="xml">
|
||||
<field name="code" position="after">
|
||||
<field name="is_dropship"/>
|
||||
</field>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
|
||||
</odoo>
|
||||
Reference in New Issue
Block a user