mirror of
https://github.com/OCA/stock-logistics-warehouse.git
synced 2025-01-21 14:27:28 +02:00
When you organize the work into your warehouse you could need to search for pickings related to a specific commercial entity. This use case could be motivated by the fact that pickings for the same commercial entity are usually delivered together. This addon add on the picking form the 'Commercial Entity' field the related partner is part of. This field is readonly and comes from the partner information. It also allows you to quickly search for pickings related to a specific commercial entity and to group by this field in the picking tree view.
31 lines
976 B
Python
31 lines
976 B
Python
# Copyright 2023 ACSONE SA/NV
|
|
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
|
|
|
|
import logging
|
|
|
|
from odoo.tools import sql
|
|
|
|
_logger = logging.getLogger(__name__)
|
|
|
|
|
|
def pre_init_hook(cr):
|
|
"""Initialise the commercial_partner_id field on stock.picking"""
|
|
if not sql.column_exists(cr, "stock_picking", "commercial_partner_id"):
|
|
_logger.info("Create column commercial_partner_id on stock_picking")
|
|
cr.execute(
|
|
"""
|
|
ALTER TABLE stock_picking ADD COLUMN commercial_partner_id integer;
|
|
"""
|
|
)
|
|
_logger.info("Init commercial_partner_id on stock_picking")
|
|
cr.execute(
|
|
"""
|
|
UPDATE stock_picking
|
|
SET commercial_partner_id = res_partner.commercial_partner_id
|
|
FROM res_partner
|
|
WHERE
|
|
stock_picking.partner_id = res_partner.id;
|
|
"""
|
|
)
|
|
_logger.info(f"{cr.rowcount} rows updated in stock_picking")
|