Browse Source

[MIG][12.0] pos_to_weight_by_product_uom

pull/368/head
Sylvain LE GAL 5 years ago
parent
commit
2ba5c3c728
  1. 121
      pos_to_weight_by_product_uom/README.rst
  2. 1
      pos_to_weight_by_product_uom/__init__.py
  3. 24
      pos_to_weight_by_product_uom/__manifest__.py
  4. 28
      pos_to_weight_by_product_uom/__openerp__.py
  5. 12
      pos_to_weight_by_product_uom/demo/product_uom_categ_demo.xml
  6. 11
      pos_to_weight_by_product_uom/demo/product_uom_demo.xml
  7. 11
      pos_to_weight_by_product_uom/demo/res_groups.xml
  8. 12
      pos_to_weight_by_product_uom/demo/uom_category.xml
  9. 11
      pos_to_weight_by_product_uom/demo/uom_uom.xml
  10. 5
      pos_to_weight_by_product_uom/models/__init__.py
  11. 15
      pos_to_weight_by_product_uom/models/product_product.py
  12. 17
      pos_to_weight_by_product_uom/models/product_template.py
  13. 7
      pos_to_weight_by_product_uom/models/uom_category.py
  14. 7
      pos_to_weight_by_product_uom/models/uom_uom.py
  15. 14
      pos_to_weight_by_product_uom/readme/CONFIGURE.rst
  16. 2
      pos_to_weight_by_product_uom/readme/CONTRIBUTORS.rst
  17. 30
      pos_to_weight_by_product_uom/readme/DESCRIPTION.rst
  18. 5
      pos_to_weight_by_product_uom/readme/USAGE.rst
  19. BIN
      pos_to_weight_by_product_uom/static/description/uom_categ_button_toweigh.png
  20. BIN
      pos_to_weight_by_product_uom/static/description/uom_categ_change_toweigh.png
  21. BIN
      pos_to_weight_by_product_uom/static/description/uom_categ_toweigh.png
  22. BIN
      pos_to_weight_by_product_uom/static/description/uom_change_toweigh.png
  23. BIN
      pos_to_weight_by_product_uom/static/description/uom_pos_change_toweigh.png
  24. BIN
      pos_to_weight_by_product_uom/static/description/uom_pos_change_toweigh_checked.png
  25. BIN
      pos_to_weight_by_product_uom/static/description/uom_toweigh.png
  26. 54
      pos_to_weight_by_product_uom/views/pos_to_weight.xml
  27. 28
      pos_to_weight_by_product_uom/views/view_uom_category.xml
  28. 27
      pos_to_weight_by_product_uom/views/view_uom_uom.xml

121
pos_to_weight_by_product_uom/README.rst

@ -1,117 +1,4 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: https://www.gnu.org/licenses/agpl
:alt: License: AGPL-3
==============
Pos to weight by product
==============
Motivation
============
At the moment, when we create a new product and choose the unity of measure **kg**,
we have to tick the checkbox 'To Weigh With Scale' in the Point of Sale part.
We want to speed the process of creating a new product, avoiding filling manually this parameter.
Brief presentation
============
This module adds the field **'To weigh'** in UOM categories (set to **false** by default).
.. image:: /pos_to_weight_by_product_uom/static/description/uom_categ_toweigh.png
:alt: Categories of unities of measure
:width: 900
**→** This field affects every unities contained in this category.
.. image:: /pos_to_weight_by_product_uom/static/description/uom_toweigh.png
:alt: Unities of measure with field 'To weigh'
:width: 900
**→** **AND** it is linked with the parameter **to_weight** in product.template used for example in the Point of Sale app.
.. image:: /pos_to_weight_by_product_uom/static/description/uom_pos_change_toweigh_checked.png
:alt: Change the field 'to weigh' for every product
:width: 300
Installation
============
To install this module, you need to :
* install the official apps : Sales Management and Point of Sale
* install this module with the installation button
* active settings "Allow using different units of measure" in Settings > Configuration > Sales > Quotations and Sales Orders > Product Features
How to use this module
=============
* [Category UOM] During the creation of a category, tick the box 'To weigh'.
.. image:: /pos_to_weight_by_product_uom/static/description/uom_categ_change_toweigh.png
:alt: Change the field 'To weigh' for every category
:width: 400
* [Category UOM] You can set every product existing with the new 'To weigh' parameter
.. image:: /pos_to_weight_by_product_uom/static/description/uom_categ_button_toweigh.png
:alt: Set 'to weigh' in each product of this category
:width: 900
* [UOM] You **CAN'T** change 'To weigh' for one UOM → You have to change in Category and affect all UOM of this category.
.. image:: /pos_to_weight_by_product_uom/static/description/uom_change_toweigh.png
:alt: Can't change the field 'to weigh' for one unity of measure
:width: 900
* [Product] **However**, you're able to change this field for a specific product (in tab Sales).
.. image:: /pos_to_weight_by_product_uom/static/description/uom_pos_change_toweigh.png
:alt: Change the field 'to weigh' for every product
:width: 300
Usage
=====
* To use this module, you need to go to (link not avalaible yet):
.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/{repo_id}/{branch}
Bug Tracker
===========
Bugs are tracked on `GitHub Issues
<https://github.com/OCA/{project_repo}/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.
Credits
=======
Contributors
------------
* Quentin Dupont, GRAP <quentin.dupont@grap.coop> (http://www.grap.coop/)
* Sylvain Legal, GRAP <sylvain.legal@grap.coop> (http://www.grap.coop/)
Do not contact contributors directly about support or help with technical issues.
Maintainer
----------
.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org
This module is maintained by the OCA.
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.
To contribute to this module, please visit https://odoo-community.org.
.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

1
pos_to_weight_by_product_uom/__init__.py

@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import models from . import models

24
pos_to_weight_by_product_uom/__manifest__.py

@ -0,0 +1,24 @@
# Copyright 2017, Grap
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Pos to weight by product uom",
"summary": "Make 'To Weight' default value"
" depending on product UoM settings",
"version": "12.0.1.0.0",
"website": "https://github.com/OCA/pos",
"author": "GRAP, Odoo Community Association (OCA)",
"license": "AGPL-3",
"installable": True,
"depends": [
"point_of_sale",
],
"data": [
'views/view_uom_uom.xml',
'views/view_uom_category.xml',
],
'demo': [
'demo/res_groups.xml',
'demo/uom_category.xml',
'demo/uom_uom.xml',
]
}

28
pos_to_weight_by_product_uom/__openerp__.py

@ -1,28 +0,0 @@
# -*- coding: utf-8 -*-
# Copyright 2017, Grap
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Pos to weight by product uom",
"summary": "Module summary",
"version": "8.0.1.0.0",
"category": "Uncategorized",
"website": "https://github.com/OCA/pos",
"author": "GRAP, Odoo Community Association (OCA)",
"license": "AGPL-3",
"application": False,
"installable": True,
"external_dependencies": {
"python": [],
"bin": [],
},
"depends": [
"product",
],
"data": [
'views/pos_to_weight.xml',
],
'demo': [
'demo/product_uom_categ_demo.xml',
'demo/product_uom_demo.xml'
]
}

12
pos_to_weight_by_product_uom/demo/product_uom_categ_demo.xml

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017, Grap
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<openerp><data>
<record model="product.uom.categ" id="product_uom_categ_to_weigh">
<field name="name">Demo - New Category To Weigh</field>
<field name="to_weigh">True</field>
</record>
</data></openerp>

11
pos_to_weight_by_product_uom/demo/product_uom_demo.xml

@ -1,11 +0,0 @@
<!-- Copyright 2017, Grap
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<openerp><data>
<record model="product.uom" id="product_uom_to_weigh">
<field name="name">Demo - New Uom To Weigh</field>
<field name="category_id" ref="pos_to_weight_by_product_uom.product_uom_categ_to_weigh"/>
</record>
</data></openerp>

11
pos_to_weight_by_product_uom/demo/res_groups.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017, Grap
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="res.groups" id="uom.group_uom">
<field name="users" eval="[(4, ref('base.user_admin'))]"/>
</record>
</odoo>

12
pos_to_weight_by_product_uom/demo/uom_category.xml

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017, Grap
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="uom.category" id="uom_category_to_weigh">
<field name="name">Demo - New Category To Weigh</field>
<field name="to_weigh">True</field>
</record>
</odoo>

11
pos_to_weight_by_product_uom/demo/uom_uom.xml

@ -0,0 +1,11 @@
<!-- Copyright 2017, Grap
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record model="uom.uom" id="uom_uom_to_weigh">
<field name="name">Demo - New Uom To Weigh</field>
<field name="category_id" ref="pos_to_weight_by_product_uom.uom_category_to_weigh"/>
</record>
</odoo>

5
pos_to_weight_by_product_uom/models/__init__.py

@ -1,6 +1,5 @@
# coding: utf-8
from . import product_product from . import product_product
from . import product_template from . import product_template
from . import product_uom
from . import product_uom_categ
from . import uom_uom
from . import uom_category

15
pos_to_weight_by_product_uom/models/product_product.py

@ -1,19 +1,16 @@
# coding: utf-8
# Copyright (C) 2018 - Today: GRAP (http://www.grap.coop) # Copyright (C) 2018 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain) # @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import api, models
from odoo import api, models
class ProductProduct(models.Model): class ProductProduct(models.Model):
_inherit = 'product.product' _inherit = 'product.product'
@api.multi
def onchange_uom(self, uom_id, uom_po_id):
res = super(ProductProduct, self).onchange_uom(uom_id, uom_po_id)
if uom_id:
res = res or {}
val = res.setdefault('value', {})
val['to_weight'] = self.env['product.uom'].browse(uom_id).to_weigh
@api.onchange('uom_id', 'uom_po_id')
def _onchange_uom(self):
res = super(ProductProduct, self)._onchange_uom()
if self.uom_id:
self.to_weight = self.uom_id.to_weigh
return res return res

17
pos_to_weight_by_product_uom/models/product_template.py

@ -1,20 +1,15 @@
# coding: utf-8
# Copyright (C) 2017 - Today: GRAP (http://www.grap.coop) # Copyright (C) 2017 - Today: GRAP (http://www.grap.coop)
# @author: Quentin DUPONT <quentin.dupont@grap.coop> # @author: Quentin DUPONT <quentin.dupont@grap.coop>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html). # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from openerp import api, models
from odoo import api, models
class ProductTemplate(models.Model): class ProductTemplate(models.Model):
_inherit = 'product.template' _inherit = 'product.template'
@api.multi
def onchange_uom(self, uom_id, uom_po_id):
res = super(ProductTemplate, self).onchange_uom(uom_id, uom_po_id)
if uom_id:
res = res and res or {}
if not res.get('value', False):
res['value'] = {}
res['value']['to_weight'] =\
self.env['product.uom'].browse(uom_id).to_weigh
@api.onchange('uom_id')
def _onchange_uom_id(self):
res = super(ProductTemplate, self)._onchange_uom_id()
if self.uom_id:
self.to_weight = self.uom_id.to_weigh
return res return res

7
pos_to_weight_by_product_uom/models/product_uom_categ.py → pos_to_weight_by_product_uom/models/uom_category.py

@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright 2017, Grap # Copyright 2017, Grap
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import fields, models, api
from odoo import fields, models, api
class ProductUomCateg(models.Model):
_inherit = 'product.uom.categ'
class UomCategory(models.Model):
_inherit = 'uom.category'
to_weigh = fields.Boolean('To weigh', default=False) to_weigh = fields.Boolean('To weigh', default=False)

7
pos_to_weight_by_product_uom/models/product_uom.py → pos_to_weight_by_product_uom/models/uom_uom.py

@ -1,12 +1,11 @@
# -*- coding: utf-8 -*-
# Copyright 2017, Grap # Copyright 2017, Grap
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). # License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import fields, models
from odoo import fields, models
class ProductUom(models.Model):
_inherit = 'product.uom'
class UomtUom(models.Model):
_inherit = 'uom.uom'
to_weigh = fields.Boolean( to_weigh = fields.Boolean(
related='category_id.to_weigh', related='category_id.to_weigh',

14
pos_to_weight_by_product_uom/readme/CONFIGURE.rst

@ -0,0 +1,14 @@
* active settings "Allow using different units of measure" in Settings > Configuration > Sales > Quotations and Sales Orders > Product Features
* During the creation of a category, tick the box 'To weigh'.
.. image:: ../static/description/uom_categ_change_toweigh.png
:alt: Change the field 'To weigh' for every category
:width: 400
* You can set every product existing with the new 'To weigh' parameter
.. image:: ../static/description/uom_categ_button_toweigh.png
:alt: Set 'to weigh' in each product of this category
:width: 900

2
pos_to_weight_by_product_uom/readme/CONTRIBUTORS.rst

@ -0,0 +1,2 @@
* Quentin Dupont, GRAP <quentin.dupont@grap.coop> (http://www.grap.coop/)
* Sylvain LE GAL <https://twitter.com/legalsylvain>

30
pos_to_weight_by_product_uom/readme/DESCRIPTION.rst

@ -0,0 +1,30 @@
At the moment, when we create a new product and choose the unity of measure **kg**,
we have to tick the checkbox 'To Weigh With Scale' in the Point of Sale part.
We want to speed the process of creating a new product, avoiding filling manually this parameter.
This module adds the field **'To weigh'** in UOM categories (set to **false** by default).
.. image:: ../static/description/uom_categ_toweigh.png
:alt: Categories of unities of measure
:width: 900
**→** This field affects every unities contained in this category.
.. image:: ../static/description/uom_toweigh.png
:alt: Unities of measure with field 'To weigh'
:width: 900
**→** **AND** it is linked with the parameter **to_weight** in product.template used for example in the Point of Sale app.
.. image:: ../static/description/uom_pos_change_toweigh_checked.png
:alt: Change the field 'to weigh' for every product
:width: 300
* You **CAN'T** change 'To weigh' for one UOM → You have to change in Category and affect all UOM of this category.
.. image:: ../static/description/uom_change_toweigh.png
:alt: Can't change the field 'to weigh' for one unity of measure
:width: 900

5
pos_to_weight_by_product_uom/readme/USAGE.rst

@ -0,0 +1,5 @@
You're able to change this field for a specific product (in tab Sales).
.. image:: ../static/description/uom_pos_change_toweigh.png
:alt: Change the field 'to weigh' for a specific
:width: 300

BIN
pos_to_weight_by_product_uom/static/description/uom_categ_button_toweigh.png

Before

Width: 969  |  Height: 221  |  Size: 18 KiB

After

Width: 558  |  Height: 214  |  Size: 17 KiB

BIN
pos_to_weight_by_product_uom/static/description/uom_categ_change_toweigh.png

Before

Width: 490  |  Height: 178  |  Size: 12 KiB

After

Width: 560  |  Height: 168  |  Size: 13 KiB

BIN
pos_to_weight_by_product_uom/static/description/uom_categ_toweigh.png

Before

Width: 1646  |  Height: 262  |  Size: 27 KiB

After

Width: 649  |  Height: 320  |  Size: 19 KiB

BIN
pos_to_weight_by_product_uom/static/description/uom_change_toweigh.png

Before

Width: 1645  |  Height: 257  |  Size: 34 KiB

After

Width: 780  |  Height: 272  |  Size: 22 KiB

BIN
pos_to_weight_by_product_uom/static/description/uom_pos_change_toweigh.png

Before

Width: 314  |  Height: 211  |  Size: 14 KiB

After

Width: 286  |  Height: 185  |  Size: 9.9 KiB

BIN
pos_to_weight_by_product_uom/static/description/uom_pos_change_toweigh_checked.png

Before

Width: 347  |  Height: 212  |  Size: 16 KiB

After

Width: 290  |  Height: 188  |  Size: 10 KiB

BIN
pos_to_weight_by_product_uom/static/description/uom_toweigh.png

Before

Width: 1558  |  Height: 382  |  Size: 54 KiB

54
pos_to_weight_by_product_uom/views/pos_to_weight.xml

@ -1,54 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Grap, OCA
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<openerp><data>
<!-- UNIT OF MEASURE CATEGS -->
<!-- Form view -->
<record id="product_uom_categ_form_view_inherit_pos_to_weight_by_product_uom" model="ir.ui.view">
<field name="model">product.uom.categ</field>
<field name="inherit_id" ref="product.product_uom_categ_form_view"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="to_weigh" />
<button name="action_recompute_to_weigh" string="Set 'to weigh' in each product of this category" type="object"/>
</field>
</field>
</record>
<!-- Tree view -->
<record id="product_uom_categ_tree_view_inherit_pos_to_weight_by_product_uom" model="ir.ui.view">
<field name="model">product.uom.categ</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="to_weigh" />
</tree>
</field>
</record>
<!-- UNITS OF MEASURE -->
<!-- Form view -->
<record id="product_uom_form_view_inherit_pos_to_weight_by_product_uom" model="ir.ui.view">
<field name="model">product.uom</field>
<field name="inherit_id" ref="product.product_uom_form_view"/>
<field name="arch" type="xml">
<field name="active" position="after">
<field name="to_weigh" />
</field>
</field>
</record>
<!-- Tree view -->
<record id="product_uom_tree_view_inherit_pos_to_weight_by_product_uom" model="ir.ui.view">
<field name="model">product.uom</field>
<field name="inherit_id" ref="product.product_uom_tree_view"/>
<field name="arch" type="xml">
<field name="category_id" position="after">
<field name="to_weigh" />
</field>
</field>
</record>
</data></openerp>

28
pos_to_weight_by_product_uom/views/view_uom_category.xml

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Grap, OCA
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="view_uom_category_form" model="ir.ui.view">
<field name="model">uom.category</field>
<field name="inherit_id" ref="uom.product_uom_categ_form_view"/>
<field name="arch" type="xml">
<field name="name" position="after">
<field name="to_weigh" />
<button name="action_recompute_to_weigh" string="Set 'to weigh' in each product of this category" type="object"/>
</field>
</field>
</record>
<record id="view_uom_category_tree" model="ir.ui.view">
<field name="model">uom.category</field>
<field name="arch" type="xml">
<tree>
<field name="name"/>
<field name="to_weigh" />
</tree>
</field>
</record>
</odoo>

27
pos_to_weight_by_product_uom/views/view_uom_uom.xml

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2017 Grap, OCA
License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl). -->
<odoo>
<record id="view_uom_uom_form" model="ir.ui.view">
<field name="model">uom.uom</field>
<field name="inherit_id" ref="uom.product_uom_form_view"/>
<field name="arch" type="xml">
<field name="active" position="after">
<field name="to_weigh" />
</field>
</field>
</record>
<record id="view_uom_uom_tree" model="ir.ui.view">
<field name="model">uom.uom</field>
<field name="inherit_id" ref="uom.product_uom_tree_view"/>
<field name="arch" type="xml">
<field name="category_id" position="after">
<field name="to_weigh" />
</field>
</field>
</record>
</odoo>
Loading…
Cancel
Save