Navigation Menu

Skip to content

Commit

Permalink
Merge PR #527 into 12.0
Browse files Browse the repository at this point in the history
Signed-off-by legalsylvain
  • Loading branch information
OCA-git-bot committed Jan 3, 2020
2 parents 645f4e5 + d094726 commit 91b025b
Show file tree
Hide file tree
Showing 22 changed files with 779 additions and 0 deletions.
75 changes: 75 additions & 0 deletions product_uom_use_type/README.rst
@@ -0,0 +1,75 @@
======================
Product UoM - Use Type
======================

.. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
.. |badge1| image:: https://img.shields.io/badge/maturity-Beta-yellow.png
:target: https://odoo-community.org/page/development-status
:alt: Beta
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-quentinDupont%2Fgrap--odoo--incubator-lightgray.png?logo=github
:target: https://github.com/quentinDupont/grap-odoo-incubator/tree/12.0-MIG_product_uom_use_type-after-rebase/product_uom_use_type
:alt: quentinDupont/grap-odoo-incubator

|badge1| |badge2| |badge3|

This module extends unities of measure (uom) by sorting them into three
categories :

* uom for sales only
* uom for purchases only
* uom for both sales and purchases (**default**).

.. figure:: https://raw.githubusercontent.com/quentinDupont/grap-odoo-incubator/12.0-MIG_product_uom_use_type-after-rebase/product_uom_use_type/static/description/use_type_list.png

**Table of contents**

.. contents::
:local:

Configuration
=============

Every unities of measure's use type will be set as **both** by default.

If you want to change that (or when you create a new unity of measure),
set use type field with sales/purchase/both.

.. figure:: https://raw.githubusercontent.com/quentinDupont/grap-odoo-incubator/12.0-MIG_product_uom_use_type-after-rebase/product_uom_use_type/static/description/use_type_form.png

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/quentinDupont/grap-odoo-incubator/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us smashing it by providing a detailed and welcomed
`feedback <https://github.com/quentinDupont/grap-odoo-incubator/issues/new?body=module:%20product_uom_use_type%0Aversion:%2012.0-MIG_product_uom_use_type-after-rebase%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* GRAP

Contributors
~~~~~~~~~~~~

* Quentin Dupont <quentin.dupont@grap.coop>
* Sylvain LE GAL <https://twitter.com/legalsylvain>

Maintainers
~~~~~~~~~~~

This module is part of the `quentinDupont/grap-odoo-incubator <https://github.com/quentinDupont/grap-odoo-incubator/tree/12.0-MIG_product_uom_use_type-after-rebase/product_uom_use_type>`_ project on GitHub.

You are welcome to contribute.
1 change: 1 addition & 0 deletions product_uom_use_type/__init__.py
@@ -0,0 +1 @@
from . import models
15 changes: 15 additions & 0 deletions product_uom_use_type/__manifest__.py
@@ -0,0 +1,15 @@
# Copyright 2019, Grap
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
{
"name": "Product UoM - Use Type",
"summary": "Define UoM for Sale and / or for Purchase purpose",
"version": "12.0.1.0.0",
"category": "Product",
"website": "https://github.com/OCA/product-attribute",
"author": "GRAP, Odoo Community Association (OCA)",
"license": "AGPL-3",
"depends": ["product"],
"data": ["views/view_product_uom.xml"],
"demo": ["demo/product_uom.xml", "demo/product_template.xml"],
"installable": True,
}
16 changes: 16 additions & 0 deletions product_uom_use_type/demo/product_template.xml
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2017 - Today: GRAP (http://www.grap.coop)
@author: Quentin DUPONT
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>

<record model="product.template" id="product_bier_faucheuse">
<field name="name">Bier - La Faucheuse</field>
<field name="uom_id" ref="uom.product_uom_litre" />
<field name="uom_po_id" ref="uom.product_uom_litre"/>
<field name="image" type="base64" file="product_uom_use_type/static/src/img/demo/bier_faucheuse.png"/>
</record>

</odoo>
27 changes: 27 additions & 0 deletions product_uom_use_type/demo/product_uom.xml
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2017 - Today: GRAP (http://www.grap.coop)
@author: Quentin DUPONT
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>

<record model="uom.uom" id="product_uom_barrel">
<field name="name">Barrel - 159L (Unit only for purchases)</field>
<field name="category_id" ref="uom.product_uom_categ_vol"/>
<field name="use_type">purchase</field>
<field name="factor_inv" eval="159.0" />
<field name="rounding">0.2</field>
<field name="uom_type">bigger</field>
</record>

<record model="uom.uom" id="product_uom_pint">
<field name="name">Pint US - 0,55L (Unit only for sales)</field>
<field name="category_id" ref="uom.product_uom_categ_vol"/>
<field name="use_type">sale</field>
<field name="factor" eval="0.55" />
<field name="rounding" eval="0.001" />
<field name="uom_type">smaller</field>
</record>

</odoo>
13 changes: 13 additions & 0 deletions product_uom_use_type/demo/res_groups.xml
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (C) 2018 - Today: GRAP (http://www.grap.coop)
@author: Sylvain LE GAL (https://twitter.com/legalsylvain)
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
-->
<odoo>

<record id="uom.group_uom" model="res.groups">
<field name="users" eval="[(4, ref('base.user_admin'))]"/>
</record>

</odoo>
57 changes: 57 additions & 0 deletions product_uom_use_type/i18n/fr.po
@@ -0,0 +1,57 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * product_uom_use_type
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 8.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-10-16 12:06+0000\n"
"PO-Revision-Date: 2017-10-16 12:06+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: product_uom_use_type
#: model:product.uom,name:product_uom_use_type.product_uom_barrel
msgid "Barrel - 159L (Unit only for purchases)"
msgstr "Fût - 159L (Unité valable seulement à l'achat)"

#. module: product_uom_use_type
#: model:product.uom,name:product_uom_use_type.product_uom_pint
msgid "Pint US - 0,55L (Unit only for sales)"
msgstr "Pinte US - 0,55L (Unité valable seulement à la vente)"

#. module: product_uom_use_type
#: model:ir.model,name:product_uom_use_type.model_product_template
msgid "Product Template"
msgstr "Modèle d'article"

#. module: product_uom_use_type
#: model:ir.model,name:product_uom_use_type.model_product_uom
msgid "Product Unit of Measure"
msgstr "Unité de mesure d'article"

#. module: product_uom_use_type
#: selection:product.uom,use_type:0
msgid "Unit available for purchases"
msgstr "Achat uniquement"

#. module: product_uom_use_type
#: selection:product.uom,use_type:0
msgid "Unit available for sales"
msgstr "Vente uniquement"

#. module: product_uom_use_type
#: selection:product.uom,use_type:0
msgid "Unit available for sales and purchases"
msgstr "Achat et vente"

#. module: product_uom_use_type
#: field:product.uom,use_type:0
msgid "Use type"
msgstr "Type d'usage"

3 changes: 3 additions & 0 deletions product_uom_use_type/models/__init__.py
@@ -0,0 +1,3 @@
from . import product_template
from . import product_product
from . import product_uom
14 changes: 14 additions & 0 deletions product_uom_use_type/models/product_product.py
@@ -0,0 +1,14 @@
# Copyright (C) 2018 - Today: GRAP (http://www.grap.coop)
# @author: Sylvain LE GAL (https://twitter.com/legalsylvain)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, models


class ProductProduct(models.Model):
_inherit = "product.product"

@api.onchange("uom_id", "uom_po_id")
def _onchange_uom(self):
if self.uom_id.use_type != "sale":
super(ProductProduct, self)._onchange_uom()
20 changes: 20 additions & 0 deletions product_uom_use_type/models/product_template.py
@@ -0,0 +1,20 @@
# Copyright (C) 2017 - Today: GRAP (http://www.grap.coop)
# @author: Quentin DUPONT <quentin.dupont@grap.coop>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).

from odoo import api, fields, models


class ProductTemplate(models.Model):
_inherit = "product.template"

uom_id = fields.Many2one(domain=[("use_type", "in", ("sale", "both"))])

uom_po_id = fields.Many2one(
domain=[("use_type", "in", ("purchase", "both"))]
)

@api.onchange("uom_id")
def _onchange_uom_id(self):
if self.uom_id.use_type != "sale":
super(ProductTemplate, self)._onchange_uom_id()
18 changes: 18 additions & 0 deletions product_uom_use_type/models/product_uom.py
@@ -0,0 +1,18 @@
# Copyright 2019, Grap
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo import fields, models


class ProductUom(models.Model):
_inherit = "uom.uom"

use_type = fields.Selection(
[
("sale", "Unit available for sales"),
("purchase", "Unit available for purchases"),
("both", "Unit available for sales and purchases"),
],
required=True,
default="both",
)
6 changes: 6 additions & 0 deletions product_uom_use_type/readme/CONFIGURE.rst
@@ -0,0 +1,6 @@
Every unities of measure's use type will be set as **both** by default.

If you want to change that (or when you create a new unity of measure),
set use type field with sales/purchase/both.

.. figure:: ../static/description/use_type_form.png
2 changes: 2 additions & 0 deletions product_uom_use_type/readme/CONTRIBUTORS.rst
@@ -0,0 +1,2 @@
* Quentin Dupont <quentin.dupont@grap.coop>
* Sylvain LE GAL <https://twitter.com/legalsylvain>
8 changes: 8 additions & 0 deletions product_uom_use_type/readme/DESCRIPTION.rst
@@ -0,0 +1,8 @@
This module extends unities of measure (uom) by sorting them into three
categories :

* uom for sales only
* uom for purchases only
* uom for both sales and purchases (**default**).

.. figure:: ../static/description/use_type_list.png
Binary file added product_uom_use_type/static/description/icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 91b025b

Please sign in to comment.