Browse Source

[ADD] new module pos_to_weight_by_product_uom

pull/229/merge
Quentin Dupont 7 years ago
committed by Sylvain LE GAL
parent
commit
a8cd4e6731
  1. 117
      pos_to_weight_by_product_uom/README.rst
  2. 4
      pos_to_weight_by_product_uom/__init__.py
  3. 28
      pos_to_weight_by_product_uom/__openerp__.py
  4. 12
      pos_to_weight_by_product_uom/demo/product_uom_categ_demo.xml
  5. 11
      pos_to_weight_by_product_uom/demo/product_uom_demo.xml
  6. 48
      pos_to_weight_by_product_uom/i18n/fr.po
  7. 6
      pos_to_weight_by_product_uom/models/__init__.py
  8. 18
      pos_to_weight_by_product_uom/models/product_template.py
  9. 13
      pos_to_weight_by_product_uom/models/product_uom.py
  10. 18
      pos_to_weight_by_product_uom/models/product_uom_categ.py
  11. BIN
      pos_to_weight_by_product_uom/static/description/icon.png
  12. BIN
      pos_to_weight_by_product_uom/static/description/uom_categ_button_toweigh.png
  13. BIN
      pos_to_weight_by_product_uom/static/description/uom_categ_change_toweigh.png
  14. BIN
      pos_to_weight_by_product_uom/static/description/uom_categ_toweigh.png
  15. BIN
      pos_to_weight_by_product_uom/static/description/uom_change_toweigh.png
  16. BIN
      pos_to_weight_by_product_uom/static/description/uom_pos_change_toweigh.png
  17. BIN
      pos_to_weight_by_product_uom/static/description/uom_pos_change_toweigh_checked.png
  18. BIN
      pos_to_weight_by_product_uom/static/description/uom_toweigh.png
  19. 54
      pos_to_weight_by_product_uom/views/pos_to_weight.xml

117
pos_to_weight_by_product_uom/README.rst

@ -0,0 +1,117 @@
.. 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.

4
pos_to_weight_by_product_uom/__init__.py

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

28
pos_to_weight_by_product_uom/__openerp__.py

@ -0,0 +1,28 @@
# -*- 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

@ -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). -->
<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

@ -0,0 +1,11 @@
<!-- 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>

48
pos_to_weight_by_product_uom/i18n/fr.po

@ -0,0 +1,48 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * pos_to_weight_by_product_uom
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-11-13 12:19+0000\n"
"PO-Revision-Date: 2017-11-13 12:19+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: pos_to_weight_by_product_uom
#: model:product.uom.categ,name:pos_to_weight_by_product_uom.product_uom_categ_to_weigh
msgid "Demo - New Category To Weigh"
msgstr "Demo - Nouvelle Catégorie à peser"
#. module: pos_to_weight_by_product_uom
#: model:product.uom,name:pos_to_weight_by_product_uom.product_uom_to_weigh
msgid "Demo - New Uom To Weigh"
msgstr "Demo - Nouvelle UdM à peser"
#. module: pos_to_weight_by_product_uom
#: model:ir.model,name:pos_to_weight_by_product_uom.model_product_template
msgid "Product Template"
msgstr "Modèle d'article"
#. module: pos_to_weight_by_product_uom
#: model:ir.model,name:pos_to_weight_by_product_uom.model_product_uom
msgid "Product Unit of Measure"
msgstr "Unité de mesure d'article"
#. module: pos_to_weight_by_product_uom
#: model:ir.model,name:pos_to_weight_by_product_uom.model_product_uom_categ
msgid "Product uom categ"
msgstr "Catégorie d'UdM d'article"
#. module: pos_to_weight_by_product_uom
#: field:product.uom,to_weigh:0
#: field:product.uom.categ,to_weigh:0
msgid "To weigh"
msgstr "À peser"

6
pos_to_weight_by_product_uom/models/__init__.py

@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from . import product_template
from . import product_uom
from . import product_uom_categ

18
pos_to_weight_by_product_uom/models/product_template.py

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright 2017, Grap
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import api, models
class ProductTemplate(models.Model):
_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:
if res.get('value', False):
res['value']['to_weight'] =\
self.env['product.uom'].browse(uom_id).to_weigh
return res

13
pos_to_weight_by_product_uom/models/product_uom.py

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

18
pos_to_weight_by_product_uom/models/product_uom_categ.py

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# Copyright 2017, Grap
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
from openerp import fields, models, api
class ProductUomCateg(models.Model):
_inherit = 'product.uom.categ'
to_weigh = fields.Boolean('To weigh', default=False)
@api.multi
def action_recompute_to_weigh(self):
for categ in self:
domain = [('uom_id.category_id', '=', categ.id)]
products = self.env['product.template'].search(domain)
products.write({'to_weight': categ.to_weigh})

BIN
pos_to_weight_by_product_uom/static/description/icon.png

After

Width: 809  |  Height: 809  |  Size: 477 KiB

BIN
pos_to_weight_by_product_uom/static/description/uom_categ_button_toweigh.png

After

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

BIN
pos_to_weight_by_product_uom/static/description/uom_categ_change_toweigh.png

After

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

BIN
pos_to_weight_by_product_uom/static/description/uom_categ_toweigh.png

After

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

BIN
pos_to_weight_by_product_uom/static/description/uom_change_toweigh.png

After

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

BIN
pos_to_weight_by_product_uom/static/description/uom_pos_change_toweigh.png

After

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

BIN
pos_to_weight_by_product_uom/static/description/uom_pos_change_toweigh_checked.png

After

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

BIN
pos_to_weight_by_product_uom/static/description/uom_toweigh.png

After

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

54
pos_to_weight_by_product_uom/views/pos_to_weight.xml

@ -0,0 +1,54 @@
<?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>
Loading…
Cancel
Save