Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions product_main_seller/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
.. image:: https://odoo-community.org/readme-banner-image
:target: https://odoo-community.org/get-involved?utm_source=readme
:alt: Odoo Community Association

===================
Product Main Vendor
===================

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:c353b8931ca2140d6d80974f00d4e5e073b737283dc2770fe718a8842cd6bd4e
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/license-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fpurchase--workflow-lightgray.png?logo=github
:target: https://github.com/OCA/purchase-workflow/tree/19.0/product_main_seller
:alt: OCA/purchase-workflow
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/purchase-workflow-19-0/purchase-workflow-19-0-product_main_seller
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/purchase-workflow&target_branch=19.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

This module extends the Odoo Product module to compute and display the
main Vendor of each products. The main vendor is the first vendor in the
vendors list.

|image1|

.. |image1| image:: https://raw.githubusercontent.com/OCA/purchase-workflow/19.0/product_main_seller/static/description/product_tree_view.png

**Table of contents**

.. contents::
:local:

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/purchase-workflow/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/purchase-workflow/issues/new?body=module:%20product_main_seller%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
-------

* GRAP

Contributors
------------

- Quentin Dupont (quentin.dupont@grap.coop)

Maintainers
-----------

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-legalsylvain| image:: https://github.com/legalsylvain.png?size=40px
:target: https://github.com/legalsylvain
:alt: legalsylvain
.. |maintainer-quentinDupont| image:: https://github.com/quentinDupont.png?size=40px
:target: https://github.com/quentinDupont
:alt: quentinDupont

Current `maintainers <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-legalsylvain| |maintainer-quentinDupont|

This module is part of the `OCA/purchase-workflow <https://github.com/OCA/purchase-workflow/tree/19.0/product_main_seller>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
2 changes: 2 additions & 0 deletions product_main_seller/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from . import models
from .hooks import pre_init_hook
21 changes: 21 additions & 0 deletions product_main_seller/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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).

{
"name": "Product Main Vendor",
"summary": "Main Vendor for a product",
"version": "19.0.1.0.0",
"category": "Purchase",
"author": "GRAP,Odoo Community Association (OCA)",
"website": "https://github.com/OCA/purchase-workflow",
"license": "AGPL-3",
"depends": ["purchase"],
"maintainers": ["legalsylvain", "quentinDupont"],
"data": [
"views/view_product_product.xml",
"views/view_product_template.xml",
],
"installable": True,
"pre_init_hook": "pre_init_hook",
}
38 changes: 38 additions & 0 deletions product_main_seller/hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Copyright 2024-Today - Sylvain Le GAL (GRAP)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging

_logger = logging.getLogger(__name__)


def pre_init_hook(env):
_logger.info("Initializing column main_seller_id on table product_template")
cr = env.cr
cr.execute(
"""
ALTER TABLE product_template
ADD COLUMN IF NOT EXISTS main_seller_id integer;
"""
)
cr.execute(
"""
WITH numbered_supplierinfos as (
SELECT *, ROW_number() over (
partition BY product_tmpl_id
ORDER BY sequence, min_qty desc, price
) as row_number
FROM product_supplierinfo
),

first_supplierinfos as (
SELECT * from numbered_supplierinfos
WHERE row_number = 1
)

UPDATE product_template pt
SET main_seller_id = first_supplierinfos.partner_id
FROM first_supplierinfos
WHERE pt.id = first_supplierinfos.product_tmpl_id;
"""
)
37 changes: 37 additions & 0 deletions product_main_seller/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_main_seller
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2024-07-08 20:26+0000\n"
"PO-Revision-Date: 2024-07-08 20:26+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: product_main_seller
#: model:ir.model.fields,field_description:product_main_seller.field_product_product__main_seller_id
#: model:ir.model.fields,field_description:product_main_seller.field_product_template__main_seller_id
#: model_terms:ir.ui.view,arch_db:product_main_seller.view_product_template_search
msgid "Main Vendor"
msgstr "Fournisseur principal"

#. module: product_main_seller
#: model:ir.model,name:product_main_seller.model_product_template
msgid "Product"
msgstr "Produit"

#. module: product_main_seller
#: model:ir.model.fields,help:product_main_seller.field_product_product__main_seller_id
#: model:ir.model.fields,help:product_main_seller.field_product_template__main_seller_id
msgid "Put your supplier info in first position to set as main vendor"
msgstr ""
"Définir une information fournisseur en première position pour le définir "
"comme fournisseur principal"
37 changes: 37 additions & 0 deletions product_main_seller/i18n/it.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_main_seller
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"PO-Revision-Date: 2024-09-06 15:06+0000\n"
"Last-Translator: mymage <stefano.consolaro@mymage.it>\n"
"Language-Team: none\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.6.2\n"

#. module: product_main_seller
#: model:ir.model.fields,field_description:product_main_seller.field_product_product__main_seller_id
#: model:ir.model.fields,field_description:product_main_seller.field_product_template__main_seller_id
#: model_terms:ir.ui.view,arch_db:product_main_seller.view_product_template_search
msgid "Main Vendor"
msgstr "Fornitore principale"

#. module: product_main_seller
#: model:ir.model,name:product_main_seller.model_product_template
msgid "Product"
msgstr "Prodotto"

#. module: product_main_seller
#: model:ir.model.fields,help:product_main_seller.field_product_product__main_seller_id
#: model:ir.model.fields,help:product_main_seller.field_product_template__main_seller_id
msgid "Put your supplier info in first position to set as main vendor"
msgstr ""
"Inserire le informazioni fornitore nella prima posizione per impostarlo come "
"fornitore principale"
38 changes: 38 additions & 0 deletions product_main_seller/i18n/nl.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_main_seller
# bosd <c5e2fd43-d292-4c90-9d1f-74ff3436329a@anonaddy.me>, 2025.
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 16.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: bosd <c5e2fd43-d292-4c90-9d1f-74ff3436329a@anonaddy.me>\n"
"Language-Team: Dutch\n"
"Language: nl\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"PO-Revision-Date: 2025-04-18 13:34+0200\n"
"X-Generator: Gtranslator 47.1\n"

#. module: product_main_seller
#: model:ir.model.fields,field_description:product_main_seller.field_product_product__main_seller_id
#: model:ir.model.fields,field_description:product_main_seller.field_product_template__main_seller_id
#: model_terms:ir.ui.view,arch_db:product_main_seller.view_product_template_search
msgid "Main Vendor"
msgstr "Hoofdleverancier"

#. module: product_main_seller
#: model:ir.model,name:product_main_seller.model_product_template
msgid "Product"
msgstr "Product"

#. module: product_main_seller
#: model:ir.model.fields,help:product_main_seller.field_product_product__main_seller_id
#: model:ir.model.fields,help:product_main_seller.field_product_template__main_seller_id
msgid "Put your supplier info in first position to set as main vendor"
msgstr ""
"Zet uw leverancier op de eerste plaats om deze als hoofdleverancier in te "
"stellen"
32 changes: 32 additions & 0 deletions product_main_seller/i18n/product_main_seller.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_main_seller
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 18.0\n"
"Report-Msgid-Bugs-To: \n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: product_main_seller
#: model:ir.model.fields,field_description:product_main_seller.field_product_product__main_seller_id
#: model:ir.model.fields,field_description:product_main_seller.field_product_template__main_seller_id
#: model_terms:ir.ui.view,arch_db:product_main_seller.view_product_template_search
msgid "Main Vendor"
msgstr ""

#. module: product_main_seller
#: model:ir.model,name:product_main_seller.model_product_template
msgid "Product"
msgstr ""

#. module: product_main_seller
#: model:ir.model.fields,help:product_main_seller.field_product_product__main_seller_id
#: model:ir.model.fields,help:product_main_seller.field_product_template__main_seller_id
msgid "Put your supplier info in first position to set as main vendor"
msgstr ""
1 change: 1 addition & 0 deletions product_main_seller/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import product_template
25 changes: 25 additions & 0 deletions product_main_seller/models/product_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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, fields, 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:
seller = template.variant_seller_ids.filtered(
lambda rec: rec.partner_id.active
)[:1]
template.main_seller_id = seller.partner_id if seller else False
3 changes: 3 additions & 0 deletions product_main_seller/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["whool"]
build-backend = "whool.buildapi"
1 change: 1 addition & 0 deletions product_main_seller/readme/CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Quentin Dupont (<quentin.dupont@grap.coop>)
5 changes: 5 additions & 0 deletions product_main_seller/readme/DESCRIPTION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This module extends the Odoo Product module to compute and display the
main Vendor of each products. The main vendor is the first vendor in the
vendors list.

![](../static/description/product_tree_view.png)
Binary file added product_main_seller/static/description/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading