- Restored product_main_seller addon to fix dependency chain - Addon required by product_origin_char and website_sale_aplicoop [IMP] website_sale_aplicoop: Add demo data configuration to manifest - Updated __manifest__.py to include demo data files - Demo data includes partners, suppliers, products, group orders, and sale orders - Demo data successfully loads during module installation
31 lines
1 KiB
Python
31 lines
1 KiB
Python
# Copyright (C) 2022 - Today: GRAP (http://www.grap.coop)
|
|
# @author: Quentin DUPONT (quentin.dupont@grap.coop)
|
|
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
|
|
|
|
from odoo import api
|
|
from odoo import fields
|
|
from odoo import models
|
|
|
|
|
|
class ProductTemplate(models.Model):
|
|
_inherit = "product.template"
|
|
|
|
main_seller_id = fields.Many2one(
|
|
comodel_name="res.partner",
|
|
string="Main Vendor",
|
|
help="Put your supplier info in first position to set as main vendor",
|
|
compute="_compute_main_seller_id",
|
|
store=True,
|
|
)
|
|
|
|
@api.depends("variant_seller_ids.sequence", "variant_seller_ids.partner_id.active")
|
|
def _compute_main_seller_id(self):
|
|
for template in self:
|
|
if template.variant_seller_ids:
|
|
template.main_seller_id = fields.first(
|
|
template.variant_seller_ids.filtered(
|
|
lambda seller: seller.partner_id.active
|
|
)
|
|
).partner_id
|
|
else:
|
|
template.main_seller_id = False
|