-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[14.0][ADD] purchase_order_line_seller: In purchase order line new fi…
…eld "Supplier Pricelist".
- Loading branch information
1 parent
d2b2eb9
commit d6ce743
Showing
9 changed files
with
241 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg | ||
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html | ||
:alt: License: AGPL-3 | ||
|
||
========================== | ||
Purchase order line seller | ||
========================== | ||
|
||
* In purchase order line new field "Supplier Pricelist". | ||
|
||
Bug Tracker | ||
=========== | ||
|
||
Bugs are tracked on `GitHub Issues | ||
<https://github.com/avanzosc/odoo-addons/issues>`_. In case of trouble, | ||
please check there if your issue has already been reported. If you spotted | ||
it first, help us smash it by providing detailed and welcomed feedback. | ||
|
||
Do not contact contributors directly about support or help with technical issues. | ||
|
||
Credits | ||
======= | ||
|
||
Contributors | ||
------------ | ||
|
||
* Ana Juaristi <anajuaristi@avanzosc.es> | ||
* Alfredo de la Fuente <alfredodelafuente@avanzosc.es> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from . import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright 2024 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl.html). | ||
{ | ||
"name": "Purchase Order Line Seller", | ||
"version": "14.0.1.0.0", | ||
"category": "Purchase Management", | ||
"license": "AGPL-3", | ||
"author": "AvanzOSC", | ||
"website": "https://github.com/avanzosc/odoo-addons", | ||
"depends": [ | ||
"product", | ||
"purchase", | ||
], | ||
"data": [ | ||
"views/purchase_order_view.xml", | ||
], | ||
"installable": True, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * purchase_order_line_seller | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-06-11 11:13+0000\n" | ||
"PO-Revision-Date: 2024-06-11 11:13+0000\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: purchase_order_line_seller | ||
#: model:ir.model.fields,field_description:purchase_order_line_seller.field_product_supplierinfo__display_name | ||
#: model:ir.model.fields,field_description:purchase_order_line_seller.field_purchase_order_line__display_name | ||
msgid "Display Name" | ||
msgstr "Nombre mostrado" | ||
|
||
#. module: purchase_order_line_seller | ||
#: model:ir.model.fields,field_description:purchase_order_line_seller.field_product_supplierinfo__id | ||
#: model:ir.model.fields,field_description:purchase_order_line_seller.field_purchase_order_line__id | ||
msgid "ID" | ||
msgstr "ID" | ||
|
||
#. module: purchase_order_line_seller | ||
#: model:ir.model.fields,field_description:purchase_order_line_seller.field_product_supplierinfo____last_update | ||
#: model:ir.model.fields,field_description:purchase_order_line_seller.field_purchase_order_line____last_update | ||
msgid "Last Modified on" | ||
msgstr "Última modificación el" | ||
|
||
#. module: purchase_order_line_seller | ||
#: model:ir.model,name:purchase_order_line_seller.model_purchase_order_line | ||
msgid "Purchase Order Line" | ||
msgstr "Línea de pedido de compra" | ||
|
||
#. module: purchase_order_line_seller | ||
#: model:ir.model,name:purchase_order_line_seller.model_product_supplierinfo | ||
#: model:ir.model.fields,field_description:purchase_order_line_seller.field_purchase_order_line__seller_id | ||
msgid "Supplier Pricelist" | ||
msgstr "Tarifa de proveedor" | ||
|
||
#. module: purchase_order_line_seller | ||
#: model:ir.model.fields,field_description:purchase_order_line_seller.field_purchase_order_line__product_seller_ids | ||
msgid "Suppliers Pricelists" | ||
msgstr "Tarifas de proveedor" |
50 changes: 50 additions & 0 deletions
50
purchase_order_line_seller/i18n/purchase_order_line_seller.pot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Translation of Odoo Server. | ||
# This file contains the translation of the following modules: | ||
# * purchase_order_line_seller | ||
# | ||
msgid "" | ||
msgstr "" | ||
"Project-Id-Version: Odoo Server 14.0\n" | ||
"Report-Msgid-Bugs-To: \n" | ||
"POT-Creation-Date: 2024-06-11 11:13+0000\n" | ||
"PO-Revision-Date: 2024-06-11 11:13+0000\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: purchase_order_line_seller | ||
#: model:ir.model.fields,field_description:purchase_order_line_seller.field_product_supplierinfo__display_name | ||
#: model:ir.model.fields,field_description:purchase_order_line_seller.field_purchase_order_line__display_name | ||
msgid "Display Name" | ||
msgstr "" | ||
|
||
#. module: purchase_order_line_seller | ||
#: model:ir.model.fields,field_description:purchase_order_line_seller.field_product_supplierinfo__id | ||
#: model:ir.model.fields,field_description:purchase_order_line_seller.field_purchase_order_line__id | ||
msgid "ID" | ||
msgstr "" | ||
|
||
#. module: purchase_order_line_seller | ||
#: model:ir.model.fields,field_description:purchase_order_line_seller.field_product_supplierinfo____last_update | ||
#: model:ir.model.fields,field_description:purchase_order_line_seller.field_purchase_order_line____last_update | ||
msgid "Last Modified on" | ||
msgstr "" | ||
|
||
#. module: purchase_order_line_seller | ||
#: model:ir.model,name:purchase_order_line_seller.model_purchase_order_line | ||
msgid "Purchase Order Line" | ||
msgstr "" | ||
|
||
#. module: purchase_order_line_seller | ||
#: model:ir.model,name:purchase_order_line_seller.model_product_supplierinfo | ||
#: model:ir.model.fields,field_description:purchase_order_line_seller.field_purchase_order_line__seller_id | ||
msgid "Supplier Pricelist" | ||
msgstr "" | ||
|
||
#. module: purchase_order_line_seller | ||
#: model:ir.model.fields,field_description:purchase_order_line_seller.field_purchase_order_line__product_seller_ids | ||
msgid "Suppliers Pricelists" | ||
msgstr "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import product_supplierinfo | ||
from . import purchase_order_line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2024 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from odoo import models | ||
|
||
|
||
class ProductSupplierinfo(models.Model): | ||
_inherit = "product.supplierinfo" | ||
|
||
def name_get(self): | ||
result = [] | ||
for supplierinfo in self: | ||
product_name = ( | ||
supplierinfo.product_name | ||
if supplierinfo.product_name | ||
else supplierinfo.name.name | ||
) | ||
if supplierinfo.product_code: | ||
name = "[{}] {}".format(supplierinfo.product_code, product_name) | ||
else: | ||
name = "{}".format(product_name) | ||
result.append((supplierinfo.id, name)) | ||
return result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Copyright 2024 Alfredo de la Fuente - AvanzOSC | ||
# License AGPL-3 - See http://www.gnu.org/licenses/agpl-3.0.html | ||
from odoo import api, fields, models | ||
|
||
|
||
class PurchaseOrderLine(models.Model): | ||
_inherit = "purchase.order.line" | ||
|
||
seller_id = fields.Many2one( | ||
string="Supplier Pricelist", comodel_name="product.supplierinfo", copy=False | ||
) | ||
product_seller_ids = fields.Many2many( | ||
string="Suppliers Pricelists", | ||
comodel_name="product.supplierinfo", | ||
compute="_compute_product_seller_ids", | ||
) | ||
|
||
@api.depends("product_id") | ||
def _compute_product_seller_ids(self): | ||
for line in self: | ||
sellers = self.env["product.supplierinfo"] | ||
if line.product_id and line.product_id.seller_ids: | ||
sellers = line.product_id.seller_ids | ||
line.product_seller_ids = [(6, 0, sellers.ids)] | ||
|
||
@api.onchange("seller_id") | ||
def onchange_seller_id(self): | ||
if self.seller_id: | ||
if self.seller_id.product_name: | ||
name = "[{}] {}".format( | ||
self.seller_id.product_code, self.seller_id.product_name | ||
) | ||
else: | ||
name = "[{}] {}".format( | ||
self.seller_id.product_code, self.product_id.name | ||
) | ||
self.name = name | ||
self.price_unit = self.seller_id.price | ||
self.discount = self.seller_id.discount |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<odoo> | ||
<record id="purchase_order_form" model="ir.ui.view"> | ||
<field name="model">purchase.order</field> | ||
<field name="inherit_id" ref="purchase.purchase_order_form" /> | ||
<field name="arch" type="xml"> | ||
<xpath | ||
expr="//field[@name='order_line']/tree/field[@name='product_id']" | ||
position="after" | ||
> | ||
<field name="product_seller_ids" invisible="1" /> | ||
<field | ||
name="seller_id" | ||
optional="show" | ||
domain="[('id', 'in', product_seller_ids)]" | ||
/> | ||
</xpath> | ||
<xpath | ||
expr="//field[@name='order_line']/form//field[@name='product_id']" | ||
position="after" | ||
> | ||
<field name="product_seller_ids" invisible="1" /> | ||
<field | ||
name="seller_id" | ||
optional="show" | ||
domain="[('id', 'in', product_seller_ids)]" | ||
/> | ||
</xpath> | ||
</field> | ||
</record> | ||
</odoo> |