[IMP] stock_usability_akretion: add seller_id on orderpoints

This commit is contained in:
Alexis de Lattre
2025-05-20 10:30:29 +02:00
parent 2e93aaa55b
commit 70b66681d6
3 changed files with 30 additions and 1 deletions

View File

@@ -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):

View File

@@ -28,8 +28,20 @@
<field name="product_id" position="after">
<field name="product_barcode" optional="hide"/>
</field>
<field name="route_id" position="after">
<field name="seller_id" optional="show"/>
</field>
</field>
</record>
<record id="stock_reorder_report_search" model="ir.ui.view">
<field name="model">stock.warehouse.orderpoint</field>
<field name="inherit_id" ref="stock.stock_reorder_report_search"/>
<field name="arch" type="xml">
<field name="product_category_id" position="after">
<field name="seller_id" domain="[('parent_id', '=', False)]"/>
</field>
</field>
</record>
</odoo>