Merge pull request #13 from bakeupboys/13-16.0-add_packaging_generator
13 16.0 add packaging generator
This commit is contained in:
commit
65544c0c44
10 changed files with 93 additions and 26 deletions
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
|
|
@ -9,11 +9,11 @@
|
||||||
"program": "${config:odoo.path}/odoo-bin",
|
"program": "${config:odoo.path}/odoo-bin",
|
||||||
"console": "integratedTerminal",
|
"console": "integratedTerminal",
|
||||||
"args": [
|
"args": [
|
||||||
"--database=nfu_sale_order_batch_packaging",
|
"--database=nfu_",
|
||||||
"--addons-path=${config:odoo.addons_path},${workspaceFolder}",
|
"--addons-path=${config:odoo.addons_path},${workspaceFolder}",
|
||||||
"--limit-time-real=0",
|
"--limit-time-real=0",
|
||||||
"--limit-time-cpu=0",
|
"--limit-time-cpu=0",
|
||||||
"--update=sale_order_batch_stock",
|
// "--init=",
|
||||||
// "--update=",
|
// "--update=",
|
||||||
"--dev=xml"
|
"--dev=xml"
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ Changelog
|
||||||
|
|
||||||
|
|
||||||
:1.0.0: Initial module.
|
:1.0.0: Initial module.
|
||||||
|
:1.1.0: Add packaging
|
||||||
|
|
||||||
Bug Tracker
|
Bug Tracker
|
||||||
===========
|
===========
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
"author": "BAKEUP",
|
"author": "BAKEUP",
|
||||||
"website": "https://www.bakeup.org",
|
"website": "https://www.bakeup.org",
|
||||||
"category": "Product",
|
"category": "Product",
|
||||||
"version": "16.0.1.0.0",
|
"version": "16.0.1.1.0",
|
||||||
"depends": ["product"],
|
"depends": ["product"],
|
||||||
"data": ["views/product_template_bnn_view.xml"],
|
"data": ["views/product_bnn_views.xml"],
|
||||||
"assets": {},
|
"assets": {},
|
||||||
"license": "LGPL-3",
|
"license": "LGPL-3",
|
||||||
"installable": True,
|
"installable": True,
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
|
from . import product_product
|
||||||
from . import product_template
|
from . import product_template
|
||||||
|
|
|
||||||
12
nfu_product_bnn_attributes/models/product_product.py
Normal file
12
nfu_product_bnn_attributes/models/product_product.py
Normal file
|
|
@ -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()
|
||||||
|
|
@ -4,7 +4,30 @@ from odoo import fields, models
|
||||||
class ProductTemplate(models.Model):
|
class ProductTemplate(models.Model):
|
||||||
_inherit = "product.template"
|
_inherit = "product.template"
|
||||||
|
|
||||||
|
manufacturer_abbr = fields.Char(string="Manufacturer Abbreviation")
|
||||||
|
# Should be moved to product.product at some point
|
||||||
additional_information = fields.Char()
|
additional_information = fields.Char()
|
||||||
quality = fields.Char()
|
quality = fields.Char()
|
||||||
origin = 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
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
|
|
||||||
:1.0.0: Initial module.
|
:1.0.0: Initial module.
|
||||||
|
:1.1.0: Add packaging
|
||||||
|
|
@ -392,6 +392,8 @@ ul.auto-toc {
|
||||||
<tbody valign="top">
|
<tbody valign="top">
|
||||||
<tr class="field"><th class="field-name">1.0.0:</th><td class="field-body">Initial module.</td>
|
<tr class="field"><th class="field-name">1.0.0:</th><td class="field-body">Initial module.</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr class="field"><th class="field-name">1.1.0:</th><td class="field-body">Add packaging</td>
|
||||||
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
47
nfu_product_bnn_attributes/views/product_bnn_views.xml
Normal file
47
nfu_product_bnn_attributes/views/product_bnn_views.xml
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<odoo>
|
||||||
|
<record id="product_template_form_view" model="ir.ui.view">
|
||||||
|
<field name="name">product.template.view.inherit.bnn</field>
|
||||||
|
<field name="model">product.template</field>
|
||||||
|
<field name="inherit_id" ref="product.product_template_form_view"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<page name="general_information" position="after">
|
||||||
|
<page name="bnn" string="BNN Information">
|
||||||
|
<group>
|
||||||
|
<group name="bnn_information">
|
||||||
|
<field name="manufacturer_abbr"/>
|
||||||
|
<field name="additional_information"/>
|
||||||
|
<field name="quality"/>
|
||||||
|
<field name="origin"/>
|
||||||
|
</group>
|
||||||
|
<group name="bnn_packaging">
|
||||||
|
<field name="packaging_name"/>
|
||||||
|
<field name="packaging_qty"/>
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</page>
|
||||||
|
</page>
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<!--
|
||||||
|
Should be moved to product.product at some point
|
||||||
|
<record id="product_normal_form_view" model="ir.ui.view">
|
||||||
|
<field name="name">product.product.form.inherit.bnn</field>
|
||||||
|
<field name="model">product.product</field>
|
||||||
|
<field name="mode">primary</field>
|
||||||
|
<field name="inherit_id" ref="nfu_product_bnn_attributes.product_template_form_view"/>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<group name="bnn_information" position="inside">
|
||||||
|
<field name="additional_information"/>
|
||||||
|
<field name="quality"/>
|
||||||
|
<field name="origin"/>
|
||||||
|
</group>
|
||||||
|
<page name="bnn" position="inside">
|
||||||
|
<group name="bnn_packaging">
|
||||||
|
<field name="packaging_name"/>
|
||||||
|
<field name="packaging_qty"/>
|
||||||
|
</group>
|
||||||
|
</page>
|
||||||
|
</field>
|
||||||
|
</record> -->
|
||||||
|
</odoo>
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
<?xml version="1.0"?>
|
|
||||||
<odoo>
|
|
||||||
<record id="product_template_bnn_view" model="ir.ui.view">
|
|
||||||
<field name="name">product.template.bnn.view</field>
|
|
||||||
<field name="model">product.template</field>
|
|
||||||
<field name="inherit_id" ref="product.product_template_only_form_view"/>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<xpath expr="//page[@name='general_information']" position="after">
|
|
||||||
<page name="bnn" string="BNN Information">
|
|
||||||
<group>
|
|
||||||
<field name="additional_information"/>
|
|
||||||
<field name="manufacturer_abbr"/>
|
|
||||||
<field name="quality"/>
|
|
||||||
<field name="origin"/>
|
|
||||||
</group>
|
|
||||||
</page>
|
|
||||||
</xpath>
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</odoo>
|
|
||||||
Loading…
Reference in a new issue