From 70b66681d6f14594a611d79da0cefcc25a854085 Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 20 May 2025 10:30:29 +0200 Subject: [PATCH] [IMP] stock_usability_akretion: add seller_id on orderpoints --- .../views/product_template.xml | 2 +- .../models/stock_warehouse_orderpoint.py | 17 +++++++++++++++++ .../views/stock_warehouse_orderpoint.xml | 12 ++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/product_usability_akretion/views/product_template.xml b/product_usability_akretion/views/product_template.xml index f6989f8..490e273 100644 --- a/product_usability_akretion/views/product_template.xml +++ b/product_usability_akretion/views/product_template.xml @@ -14,7 +14,7 @@ - + diff --git a/stock_usability_akretion/models/stock_warehouse_orderpoint.py b/stock_usability_akretion/models/stock_warehouse_orderpoint.py index 1d6086d..aff93cf 100644 --- a/stock_usability_akretion/models/stock_warehouse_orderpoint.py +++ b/stock_usability_akretion/models/stock_warehouse_orderpoint.py @@ -15,6 +15,23 @@ class StockWarehouseOrderpoint(models.Model): # but all the Odoo deployments I've seen so far need 'manual' by default trigger = fields.Selection(default='manual') product_barcode = fields.Char(related='product_id.barcode', string="Product Barcode") + seller_id = fields.Many2one( + "res.partner", + compute="_compute_seller_id", + search="_search_seller_id", + string="Main Supplier") + + def _search_seller_id(self, operator, value): + # searching on the first line of a o2m is not that easy + # So we search all potential matching products + # Then we filter on the seller_id + records = self.search([("product_id.seller_ids.partner_id", operator, value)]) + records = records.filtered_domain([("seller_id", operator, value)]) + return [("id", "in", records.ids)] + + def _compute_seller_id(self): + for orderpoint in self: + orderpoint.seller_id = fields.first(orderpoint.product_id.seller_ids).partner_id def _procure_orderpoint_confirm( self, use_new_cursor=False, company_id=None, raise_user_error=True): diff --git a/stock_usability_akretion/views/stock_warehouse_orderpoint.xml b/stock_usability_akretion/views/stock_warehouse_orderpoint.xml index c9cb2d5..ac943fd 100644 --- a/stock_usability_akretion/views/stock_warehouse_orderpoint.xml +++ b/stock_usability_akretion/views/stock_warehouse_orderpoint.xml @@ -28,8 +28,20 @@ + + + + + stock.warehouse.orderpoint + + + + + + +