Skip to content

Commit

Permalink
Merge pull request #33 from guewen/10.0-add-sale_line_cost_control
Browse files Browse the repository at this point in the history
Add sale_line_cost_control
  • Loading branch information
gurneyalex committed May 31, 2017
2 parents 4581674 + 349075f commit ddc8026
Show file tree
Hide file tree
Showing 18 changed files with 618 additions and 0 deletions.
80 changes: 80 additions & 0 deletions sale_line_cost_control/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
.. image:: https://img.shields.io/badge/licence-AGPL--3-blue.svg
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3

=======================
Sale Lines Cost Control
=======================

This modules modifies the visibility of the Cost prices on Sales Order lines.
Specifically, it:

* hides the cost price on lines for normal users
* add a new group allowing to see the cost price on lines
* add a new button on lines without cost to set the current price

It allows to correct the cost of new products when users should not have
the permission to see the cost price.


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

No configuration is needed.
Users that must see the cost prices must have the "Cost Prices in Sales Orders"
group. This group can be added as inherited group in a more general group such
as "Sales / Manager".

Usage
=====

The sales order view has been modified according to the description above.
There is no special usage.

.. image:: https://odoo-community.org/website/image/ir.attachment/5784_f2813bd/datas
:alt: Try me on Runbot
:target: https://runbot.odoo-community.org/runbot/132/10.0

Known issues / Roadmap
======================

* No plans at the moment

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

Bugs are tracked on `GitHub Issues
<https://github.com/OCA/margin-analysis/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
=======

Images
------

.. image:: ./images/order-lines.png
.. image:: ./images/change-cost.png

* Odoo Community Association: `Icon <https://github.com/OCA/maintainer-tools/blob/master/template/module/static/description/icon.svg>`_.

Contributors
------------

* Guewen Baconnier <guewen.baconnier@camptocamp.com>

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.
3 changes: 3 additions & 0 deletions sale_line_cost_control/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import models
from . import wizards
20 changes: 20 additions & 0 deletions sale_line_cost_control/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)


{'name': 'Sales Lines Cost Control',
'version': '10.0.1.0.0',
'author': 'Camptocamp,Odoo Community Association (OCA)',
'license': 'AGPL-3',
'category': 'Sales',
'depends': ['sale',
'sale_margin',
],
'website': 'https://www.camptocamp.com',
'data': ['security/security.xml',
'wizards/set_sale_line_purchase_price_views.xml',
'views/sale_views.xml',
],
'installable': True,
}
112 changes: 112 additions & 0 deletions sale_line_cost_control/i18n/fr.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_line_cost_control
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-22 12:51+0000\n"
"PO-Revision-Date: 2017-05-18 09:10+0000\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"

#. module: sale_line_cost_control
#: model:ir.ui.view,arch_db:sale_line_cost_control.view_set_sale_line_purchase_price
msgid "Cancel"
msgstr "Annuler"

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_purchase_price
msgid "Cost"
msgstr "Coût"

#. module: sale_line_cost_control
#: model:ir.model.fields,help:sale_line_cost_control.field_set_sale_line_purchase_price_purchase_price
msgid ""
"Cost of the product template used for standard stock valuation in accounting "
"and used as a base price on purchase orders. Expressed in the default unit "
"of measure of the product."
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_create_uid
msgid "Created by"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_create_date
msgid "Created on"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_currency_id
msgid "Currency"
msgstr "Devise"

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_display_name
msgid "Display Name"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_id
msgid "ID"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price___last_update
msgid "Last Modified on"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_write_uid
msgid "Last Updated by"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_write_date
msgid "Last Updated on"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_sale_order_line_purchase_price_missing
msgid "Missing Cost"
msgstr "Coût manquant"

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_line_id
msgid "Sale Line"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model,name:sale_line_cost_control.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.ui.view,arch_db:sale_line_cost_control.view_set_sale_line_purchase_price
msgid "Save Cost"
msgstr "Sauvegarder le coût"

#. module: sale_line_cost_control
#: model:ir.actions.act_window,name:sale_line_cost_control.action_set_sale_line_purchase_price
#: model:ir.ui.view,arch_db:sale_line_cost_control.sale_margin_sale_order_line_tree
#: model:ir.ui.view,arch_db:sale_line_cost_control.view_set_sale_line_purchase_price
msgid "Set Cost"
msgstr "Définir le coût"

#. module: sale_line_cost_control
#: model:res.groups,name:sale_line_cost_control.group_sale_show_standard_price
msgid "Show Cost Prices in Sales Orders"
msgstr "Afficher les coûts dans les commandes de vente"

#. module: sale_line_cost_control
#: model:ir.model,name:sale_line_cost_control.model_set_sale_line_purchase_price
msgid "set.sale.line.purchase.price"
msgstr ""
109 changes: 109 additions & 0 deletions sale_line_cost_control/i18n/sale_line_cost_control.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * sale_line_cost_control
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0+e\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-05-22 12:51+0000\n"
"PO-Revision-Date: 2017-05-22 12:51+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: sale_line_cost_control
#: model:ir.ui.view,arch_db:sale_line_cost_control.view_set_sale_line_purchase_price
msgid "Cancel"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_purchase_price
msgid "Cost"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,help:sale_line_cost_control.field_set_sale_line_purchase_price_purchase_price
msgid "Cost of the product template used for standard stock valuation in accounting and used as a base price on purchase orders. Expressed in the default unit of measure of the product."
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_create_uid
msgid "Created by"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_create_date
msgid "Created on"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_currency_id
msgid "Currency"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_display_name
msgid "Display Name"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_id
msgid "ID"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price___last_update
msgid "Last Modified on"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_write_uid
msgid "Last Updated by"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_write_date
msgid "Last Updated on"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_sale_order_line_purchase_price_missing
msgid "Missing Cost"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model.fields,field_description:sale_line_cost_control.field_set_sale_line_purchase_price_line_id
msgid "Sale Line"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model,name:sale_line_cost_control.model_sale_order_line
msgid "Sales Order Line"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.ui.view,arch_db:sale_line_cost_control.view_set_sale_line_purchase_price
msgid "Save Cost"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.actions.act_window,name:sale_line_cost_control.action_set_sale_line_purchase_price
#: model:ir.ui.view,arch_db:sale_line_cost_control.sale_margin_sale_order_line_tree
#: model:ir.ui.view,arch_db:sale_line_cost_control.view_set_sale_line_purchase_price
msgid "Set Cost"
msgstr ""

#. module: sale_line_cost_control
#: model:res.groups,name:sale_line_cost_control.group_sale_show_standard_price
msgid "Show Cost Prices in Sales Orders"
msgstr ""

#. module: sale_line_cost_control
#: model:ir.model,name:sale_line_cost_control.model_set_sale_line_purchase_price
msgid "set.sale.line.purchase.price"
msgstr ""

Binary file added sale_line_cost_control/images/change-cost.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added sale_line_cost_control/images/order-lines.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions sale_line_cost_control/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# -*- coding: utf-8 -*-
from . import sale
24 changes: 24 additions & 0 deletions sale_line_cost_control/models/sale.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Copyright 2017 Camptocamp SA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html)

from odoo import api, fields, models, tools


class SaleOrderLine(models.Model):
_inherit = 'sale.order.line'

purchase_price_missing = fields.Boolean(
compute='_compute_purchase_price_missing',
string='Missing Cost',
)

@api.depends('purchase_price')
def _compute_purchase_price_missing(self):
precision_model = self.env['decimal.precision']
precision = precision_model.precision_get('Product Price')
for line in self:
line.purchase_price_missing = tools.float_is_zero(
line.purchase_price,
precision_digits=precision
)
9 changes: 9 additions & 0 deletions sale_line_cost_control/security/security.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>

<record id="group_sale_show_standard_price" model="res.groups">
<field name="name">Show Cost Prices in Sales Orders</field>
<field name="category_id" ref="base.module_category_hidden"/>
</record>

</odoo>
3 changes: 3 additions & 0 deletions sale_line_cost_control/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# -*- coding: utf-8 -*-
from . import test_sale
from . import test_set_sale_line_purchase_price
Loading

0 comments on commit ddc8026

Please sign in to comment.