From 740d1673315179c724993f6e5630765b93056c5c Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Sat, 15 Jun 2024 12:24:12 +0200 Subject: [PATCH] purchase_stock_generic_product and sale_stock_generic_product: allows the use of generic products --- purchase_stock_generic_product/README.rst | 3 +++ purchase_stock_generic_product/__init__.py | 1 + .../__manifest__.py | 18 ++++++++++++++++ .../models/__init__.py | 1 + .../models/purchase_order_line.py | 17 +++++++++++++++ sale_stock_generic_product/README.rst | 3 +++ sale_stock_generic_product/__init__.py | 1 + sale_stock_generic_product/__manifest__.py | 18 ++++++++++++++++ sale_stock_generic_product/models/__init__.py | 3 +++ .../models/sale_order_line.py | 14 +++++++++++++ .../models/stock_move.py | 14 +++++++++++++ .../models/stock_rule.py | 18 ++++++++++++++++ .../views/stock_move_line.xml | 21 +++++++++++++++++++ 13 files changed, 132 insertions(+) create mode 100644 purchase_stock_generic_product/README.rst create mode 100644 purchase_stock_generic_product/__init__.py create mode 100644 purchase_stock_generic_product/__manifest__.py create mode 100644 purchase_stock_generic_product/models/__init__.py create mode 100644 purchase_stock_generic_product/models/purchase_order_line.py create mode 100644 sale_stock_generic_product/README.rst create mode 100644 sale_stock_generic_product/__init__.py create mode 100644 sale_stock_generic_product/__manifest__.py create mode 100644 sale_stock_generic_product/models/__init__.py create mode 100644 sale_stock_generic_product/models/sale_order_line.py create mode 100644 sale_stock_generic_product/models/stock_move.py create mode 100644 sale_stock_generic_product/models/stock_rule.py create mode 100644 sale_stock_generic_product/views/stock_move_line.xml diff --git a/purchase_stock_generic_product/README.rst b/purchase_stock_generic_product/README.rst new file mode 100644 index 0000000..c7edf87 --- /dev/null +++ b/purchase_stock_generic_product/README.rst @@ -0,0 +1,3 @@ +This module **purchase_stock_generic_product** allows the use of generic products whose exact properties is written in the description. With this module, the exact product description written in the *name* field of purchase.order.line is written in the field *description_picking* of stock.move. + +The module has a twin module for sale orders: **sale_stock_generic_product**. diff --git a/purchase_stock_generic_product/__init__.py b/purchase_stock_generic_product/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/purchase_stock_generic_product/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/purchase_stock_generic_product/__manifest__.py b/purchase_stock_generic_product/__manifest__.py new file mode 100644 index 0000000..7bffe6b --- /dev/null +++ b/purchase_stock_generic_product/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2024 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Purchase Stock Generic Product', + 'version': '16.0.1.0.0', + 'category': 'Purchases', + 'license': 'AGPL-3', + 'summary': 'Generic product for purchase orders', + 'author': 'Akretion', + 'maintainers': ['alexis-via'], + "development_status": "Mature", + 'website': 'https://github.com/akretion/odoo-usability', + 'depends': ['purchase_stock'], + 'data': [], + 'installable': True, +} diff --git a/purchase_stock_generic_product/models/__init__.py b/purchase_stock_generic_product/models/__init__.py new file mode 100644 index 0000000..fa6c0e4 --- /dev/null +++ b/purchase_stock_generic_product/models/__init__.py @@ -0,0 +1 @@ +from . import purchase_order_line diff --git a/purchase_stock_generic_product/models/purchase_order_line.py b/purchase_stock_generic_product/models/purchase_order_line.py new file mode 100644 index 0000000..a018c1c --- /dev/null +++ b/purchase_stock_generic_product/models/purchase_order_line.py @@ -0,0 +1,17 @@ +# Copyright 2024 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class PurchaseOrderLine(models.Model): + _inherit = 'purchase.order.line' + + def _prepare_stock_move_vals( + self, picking, price_unit, product_uom_qty, product_uom): + vals = super()._prepare_stock_move_vals( + picking, price_unit, product_uom_qty, product_uom) + # native : product.description_pickingin or self.name + vals['description_picking'] = self.name + return vals diff --git a/sale_stock_generic_product/README.rst b/sale_stock_generic_product/README.rst new file mode 100644 index 0000000..bfb322d --- /dev/null +++ b/sale_stock_generic_product/README.rst @@ -0,0 +1,3 @@ +This module **sale_stock_generic_product** allows the use of generic products whose exact properties is written in the description. With this module, the exact product description written in the *name* field of sale.order.line is written in the field *description_picking* of stock.move and stock.move.line. + +The module has a twin module for purchase: **purchase_stock_generic_product**. diff --git a/sale_stock_generic_product/__init__.py b/sale_stock_generic_product/__init__.py new file mode 100644 index 0000000..0650744 --- /dev/null +++ b/sale_stock_generic_product/__init__.py @@ -0,0 +1 @@ +from . import models diff --git a/sale_stock_generic_product/__manifest__.py b/sale_stock_generic_product/__manifest__.py new file mode 100644 index 0000000..07b3f36 --- /dev/null +++ b/sale_stock_generic_product/__manifest__.py @@ -0,0 +1,18 @@ +# Copyright 2024 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). + +{ + 'name': 'Sale Stock Generic Product', + 'version': '16.0.1.0.0', + 'category': 'Sales', + 'license': 'AGPL-3', + 'summary': 'Generic products for sale orders', + 'author': 'Akretion', + 'maintainers': ['alexis-via'], + "development_status": "Mature", + 'website': 'https://github.com/akretion/odoo-usability', + 'depends': ['sale_stock'], + 'data': ['views/stock_move_line.xml'], + 'installable': True, +} diff --git a/sale_stock_generic_product/models/__init__.py b/sale_stock_generic_product/models/__init__.py new file mode 100644 index 0000000..d143d60 --- /dev/null +++ b/sale_stock_generic_product/models/__init__.py @@ -0,0 +1,3 @@ +from . import sale_order_line +from . import stock_rule +from . import stock_move diff --git a/sale_stock_generic_product/models/sale_order_line.py b/sale_stock_generic_product/models/sale_order_line.py new file mode 100644 index 0000000..5a12056 --- /dev/null +++ b/sale_stock_generic_product/models/sale_order_line.py @@ -0,0 +1,14 @@ +# Copyright 2024 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class SaleOrderLine(models.Model): + _inherit = 'sale.order.line' + + def _prepare_procurement_values(self, group_id=False): + vals = super()._prepare_procurement_values(group_id=group_id) + vals['description_picking'] = self.name + return vals diff --git a/sale_stock_generic_product/models/stock_move.py b/sale_stock_generic_product/models/stock_move.py new file mode 100644 index 0000000..b9e4632 --- /dev/null +++ b/sale_stock_generic_product/models/stock_move.py @@ -0,0 +1,14 @@ +# Copyright 2024 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockMove(models.Model): + _inherit = 'stock.move' + + def _prepare_move_line_vals(self, quantity=None, reserved_quant=None): + vals = super()._prepare_move_line_vals(quantity=quantity, reserved_quant=reserved_quant) + vals['description_picking'] = self.description_picking + return vals diff --git a/sale_stock_generic_product/models/stock_rule.py b/sale_stock_generic_product/models/stock_rule.py new file mode 100644 index 0000000..69e749b --- /dev/null +++ b/sale_stock_generic_product/models/stock_rule.py @@ -0,0 +1,18 @@ +# Copyright 2024 Akretion France (http://www.akretion.com/) +# @author: Alexis de Lattre +# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). + +from odoo import models + + +class StockRule(models.Model): + _inherit = 'stock.rule' + + def _get_stock_move_values( + self, product_id, product_qty, product_uom, location_dest_id, name, + origin, company_id, values): + move_vals = super()._get_stock_move_values( + product_id, product_qty, product_uom, location_dest_id, name, + origin, company_id, values) + move_vals['description_picking'] = values.get('description_picking') + return move_vals diff --git a/sale_stock_generic_product/views/stock_move_line.xml b/sale_stock_generic_product/views/stock_move_line.xml new file mode 100644 index 0000000..09dd854 --- /dev/null +++ b/sale_stock_generic_product/views/stock_move_line.xml @@ -0,0 +1,21 @@ + + + + + + + stock.move.line + + + + + + + + + +