diff --git a/.vscode/launch.json b/.vscode/launch.json index 10199d7..f7805af 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -9,11 +9,11 @@ "program": "${config:odoo.path}/odoo-bin", "console": "integratedTerminal", "args": [ - "--database=nfu_sale_order_batch_packaging", + "--database=nfu_", "--addons-path=${config:odoo.addons_path},${workspaceFolder}", "--limit-time-real=0", "--limit-time-cpu=0", - "--update=sale_order_batch_stock", + // "--init=", // "--update=", "--dev=xml" ] diff --git a/nfu_product_bnn_attributes/README.rst b/nfu_product_bnn_attributes/README.rst index 4e3438f..b2ec0ab 100644 --- a/nfu_product_bnn_attributes/README.rst +++ b/nfu_product_bnn_attributes/README.rst @@ -34,6 +34,7 @@ Changelog :1.0.0: Initial module. +:1.1.0: Add packaging Bug Tracker =========== diff --git a/nfu_product_bnn_attributes/__manifest__.py b/nfu_product_bnn_attributes/__manifest__.py index 5e7077e..92608a6 100644 --- a/nfu_product_bnn_attributes/__manifest__.py +++ b/nfu_product_bnn_attributes/__manifest__.py @@ -4,9 +4,9 @@ "author": "BAKEUP", "website": "https://www.bakeup.org", "category": "Product", - "version": "16.0.1.0.0", + "version": "16.0.1.1.0", "depends": ["product"], - "data": ["views/product_template_bnn_view.xml"], + "data": ["views/product_bnn_views.xml"], "assets": {}, "license": "LGPL-3", "installable": True, diff --git a/nfu_product_bnn_attributes/models/__init__.py b/nfu_product_bnn_attributes/models/__init__.py index e8fa8f6..18b37e8 100644 --- a/nfu_product_bnn_attributes/models/__init__.py +++ b/nfu_product_bnn_attributes/models/__init__.py @@ -1 +1,2 @@ +from . import product_product from . import product_template diff --git a/nfu_product_bnn_attributes/models/product_product.py b/nfu_product_bnn_attributes/models/product_product.py new file mode 100644 index 0000000..29ccd70 --- /dev/null +++ b/nfu_product_bnn_attributes/models/product_product.py @@ -0,0 +1,12 @@ +from odoo import models + + +class ProductProduct(models.Model): + _inherit = "product.product" + + # Should be moved to product.product at some point + # additional_information = fields.Char() + # quality = fields.Char() + # origin = fields.Char() + # packaging_qty = fields.Float(string="Packaging Quantity") + # packaging_name = fields.Char() diff --git a/nfu_product_bnn_attributes/models/product_template.py b/nfu_product_bnn_attributes/models/product_template.py index 1581bbc..81fb9a0 100644 --- a/nfu_product_bnn_attributes/models/product_template.py +++ b/nfu_product_bnn_attributes/models/product_template.py @@ -4,7 +4,30 @@ from odoo import fields, models class ProductTemplate(models.Model): _inherit = "product.template" + manufacturer_abbr = fields.Char(string="Manufacturer Abbreviation") + # Should be moved to product.product at some point additional_information = fields.Char() quality = fields.Char() origin = fields.Char() - manufacturer_abbr = fields.Char(string="Manufacturer Abbreviation") + packaging_qty = fields.Float(string="Packaging Quantity") + packaging_name = fields.Char() + + def write(self, vals): + res = super().write(vals) + if vals.get("packaging_qty") or vals.get("packaging_name"): + for product in self: + qty = vals.get("packaging_qty") or product.packaging_qty + name = vals.get("packaging_name") or product.packaging_name + product_products = self.env["product.product"].search([("product_tmpl_id", "=", product.id)]) + if qty and name: + for product_product in product_products: + packagings = self.env["product.packaging"].search( + [("product_id", "=", product_product.id)], limit=1 + ) + if packagings: + packagings.write({"name": name, "qty": qty, "sales": True}) + else: + self.env["product.packaging"].create( + {"name": name, "qty": qty, "product_id": product_product.id, "sales": True} + ) + return res diff --git a/nfu_product_bnn_attributes/readme/HISTORY.rst b/nfu_product_bnn_attributes/readme/HISTORY.rst index 962941f..e6c8ca0 100644 --- a/nfu_product_bnn_attributes/readme/HISTORY.rst +++ b/nfu_product_bnn_attributes/readme/HISTORY.rst @@ -1,2 +1,3 @@ -:1.0.0: Initial module. \ No newline at end of file +:1.0.0: Initial module. +:1.1.0: Add packaging \ No newline at end of file diff --git a/nfu_product_bnn_attributes/static/description/index.html b/nfu_product_bnn_attributes/static/description/index.html index c09ba0b..fe44d6a 100644 --- a/nfu_product_bnn_attributes/static/description/index.html +++ b/nfu_product_bnn_attributes/static/description/index.html @@ -392,6 +392,8 @@ ul.auto-toc { 1.0.0:Initial module. +1.1.0:Add packaging + diff --git a/nfu_product_bnn_attributes/views/product_bnn_views.xml b/nfu_product_bnn_attributes/views/product_bnn_views.xml new file mode 100644 index 0000000..283260f --- /dev/null +++ b/nfu_product_bnn_attributes/views/product_bnn_views.xml @@ -0,0 +1,47 @@ + + + + product.template.view.inherit.bnn + product.template + + + + + + + + + + + + + + + + + + + + + + diff --git a/nfu_product_bnn_attributes/views/product_template_bnn_view.xml b/nfu_product_bnn_attributes/views/product_template_bnn_view.xml deleted file mode 100644 index cb806f7..0000000 --- a/nfu_product_bnn_attributes/views/product_template_bnn_view.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - product.template.bnn.view - product.template - - - - - - - - - - - - - - -