Browse Source

commit inicial

Rodney Elpidio Enciso Arias 6 years ago
commit
495acd02c1
12 changed files with 335 additions and 0 deletions
  1. 9 0
      __init__.py
  2. BIN
      __init__.pyc
  3. 53 0
      __openerp__.py
  4. 59 0
      i18n/en.po
  5. 66 0
      i18n/es.po
  6. 74 0
      sale_order.py
  7. BIN
      sale_order.pyc
  8. 23 0
      sale_view.xml
  9. 25 0
      security/sale_order.xml
  10. 12 0
      stock.py
  11. BIN
      stock.pyc
  12. 14 0
      stock_view.xml

+ 9 - 0
__init__.py

@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+# For copyright and license notices, see __openerp__.py file in module root
+# directory
+##############################################################################
+from . import sale_order
+from . import stock
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

BIN
__init__.pyc


+ 53 - 0
__openerp__.py

@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+#    Copyright (C) 2015  ADHOC SA  (http://www.adhoc.com.ar)
+#    All Rights Reserved.
+#
+#    This program is free software: you can redistribute it and/or modify
+#    it under the terms of the GNU Affero General Public License as
+#    published by the Free Software Foundation, either version 3 of the
+#    License, or (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU Affero General Public License for more details.
+#
+#    You should have received a copy of the GNU Affero General Public License
+#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+{
+    'name': 'Stock availability in sales order line',
+    'version': '8.0.0.1.0',
+    'category': 'Tools',
+    'description': """
+Stock availability in sales order line
+======================================
+* Add two groups. One for seeing stock on sale orders and other to see only if or not available
+* Add an option in warehouse to disable stock warning
+
+IMPORTANT:
+----------
+    * This module could break some warnings as the ones implemented by "warning" module
+    * If you dont disable warning and give a user availbility to see only "true/false" on sale order stock, he can see stock if the warning is raised
+    """,
+    'author': 'Moldeo Interactive & ADHOC SA',
+    'website': 'http://business.moldeo.coop http://adhoc.com.ar/',
+    'license': 'AGPL-3',
+    'images': [],
+    'depends': [
+        'sale_stock'
+    ],
+    'demo': [],
+    'data': [
+        'sale_view.xml',
+        'stock_view.xml',
+        'security/sale_order.xml',
+        ],
+    'test': [],
+    'installable': True,
+}
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

+ 59 - 0
i18n/en.po

@@ -0,0 +1,59 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * sale_stock_availability
+# 
+# Translators:
+msgid ""
+msgstr ""
+"Project-Id-Version: odoo-addons (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2015-09-09 23:58+0000\n"
+"PO-Revision-Date: 2015-09-01 17:54+0000\n"
+"Last-Translator: Juan Jose Scarafia <scarafia.juanjose@gmail.com>\n"
+"Language-Team: English (http://www.transifex.com/adhoc/ingadhoc-odoo-addons-8-0/language/en/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: en\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. module: sale_stock_availability
+#: code:addons/sale_stock_availability/sale_order.py:59
+#, python-format
+msgid "Configuration Error!"
+msgstr "Configuration Error!"
+
+#. module: sale_stock_availability
+#: field:stock.warehouse,disable_sale_stock_warning:0
+msgid "Disable Sale Stock Warning"
+msgstr "Disable Sale Stock Warning"
+
+#. module: sale_stock_availability
+#: model:ir.module.category,description:sale_stock_availability.module_category_sales_stock
+msgid "Helps you see stock on quotations."
+msgstr "Helps you see stock on quotations."
+
+#. module: sale_stock_availability
+#: model:res.groups,name:sale_stock_availability.see_stock_boolean
+msgid "Only yes/no"
+msgstr "Only yes/no"
+
+#. module: sale_stock_availability
+#: model:ir.model,name:sale_stock_availability.model_sale_order_line
+msgid "Sales Order Line"
+msgstr "Sales Order Line"
+
+#. module: sale_stock_availability
+#: model:ir.module.category,name:sale_stock_availability.module_category_sales_stock
+msgid "Sales Stock Availability"
+msgstr "Sales Stock Availability"
+
+#. module: sale_stock_availability
+#: model:res.groups,name:sale_stock_availability.see_stock_value
+msgid "Stock Value"
+msgstr "Stock Value"
+
+#. module: sale_stock_availability
+#: model:ir.model,name:sale_stock_availability.model_stock_warehouse
+msgid "Warehouse"
+msgstr "Warehouse"

+ 66 - 0
i18n/es.po

@@ -0,0 +1,66 @@
+# Translation of Odoo Server.
+# This file contains the translation of the following modules:
+# * sale_stock_availability
+# 
+# Translators:
+# Juan José Scarafía <scarafia.juanjose@gmail.com>, 2016
+msgid ""
+msgstr ""
+"Project-Id-Version: sale (8.0)\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2016-05-20 22:53+0000\n"
+"PO-Revision-Date: 2016-05-24 23:16+0000\n"
+"Last-Translator: Juan José Scarafía <scarafia.juanjose@gmail.com>\n"
+"Language-Team: Spanish (http://www.transifex.com/adhoc/ingadhoc-sale-8-0/language/es/)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: \n"
+"Language: es\n"
+"Plural-Forms: nplurals=2; plural=(n != 1);\n"
+
+#. module: sale_stock_availability
+#: code:addons/sale_stock_availability/sale_order.py:59
+#, python-format
+msgid "Configuration Error!"
+msgstr "Error de Configuración!"
+
+#. module: sale_stock_availability
+#: field:stock.warehouse,disable_sale_stock_warning:0
+msgid "Disable Sale Stock Warning"
+msgstr "Desactivar Advertencia de Stock en Ventas"
+
+#. module: sale_stock_availability
+#: model:ir.module.category,description:sale_stock_availability.module_category_sales_stock
+msgid "Helps you see stock on quotations."
+msgstr "Ayuda a ver el stock en los presupuestos."
+
+#. module: sale_stock_availability
+#: model:res.groups,name:sale_stock_availability.see_stock_boolean
+msgid "Only yes/no"
+msgstr "Solo si/no"
+
+#. module: sale_stock_availability
+#: field:sale.order.line,virtual_available:0
+#: field:sale.order.line,virtual_available_boolean:0
+msgid "Saldo Stock"
+msgstr "Saldo Stock"
+
+#. module: sale_stock_availability
+#: model:ir.model,name:sale_stock_availability.model_sale_order_line
+msgid "Sales Order Line"
+msgstr "Línea pedido de venta"
+
+#. module: sale_stock_availability
+#: model:ir.module.category,name:sale_stock_availability.module_category_sales_stock
+msgid "Sales Stock Availability"
+msgstr "Disponibilidad de Existencias en Ventas"
+
+#. module: sale_stock_availability
+#: model:res.groups,name:sale_stock_availability.see_stock_value
+msgid "Stock Value"
+msgstr "Stock"
+
+#. module: sale_stock_availability
+#: model:ir.model,name:sale_stock_availability.model_stock_warehouse
+msgid "Warehouse"
+msgstr "Depósito"

+ 74 - 0
sale_order.py

@@ -0,0 +1,74 @@
+# -*- coding    : utf-8 -*-
+from openerp import fields, models, api, _
+
+
+class sale_order_line(models.Model):
+    _inherit = "sale.order.line"
+
+    @api.one
+    @api.depends(
+        'product_uom_qty',
+        'product_id')
+    def _fnct_line_stock(self):
+        available = False
+        if self.order_id.state == 'draft':
+            available = self.with_context(
+                warehouse=self.order_id.warehouse_id.id
+            ).product_id.virtual_available - self.product_uom_qty
+        self.virtual_available = available
+        if available >= 0.0:
+            available = True
+        else:
+            available = False
+        self.virtual_available_boolean = available
+
+    virtual_available = fields.Float(
+        compute="_fnct_line_stock", string='Saldo Stock')
+    virtual_available_boolean = fields.Boolean(
+        compute="_fnct_line_stock", string='Saldo Stock')
+
+    def product_id_change_with_wh(
+            self, cr, uid, ids, pricelist, product, qty=0,
+            uom=False, qty_uos=0, uos=False, name='', partner_id=False,
+            lang=False, update_tax=True, date_order=False, packaging=False,
+            fiscal_position=False, flag=False, warehouse_id=False,
+            context=None):
+        res = super(sale_order_line, self).product_id_change_with_wh(
+            cr, uid, ids, pricelist, product, qty,
+            uom, qty_uos, uos, name, partner_id,
+            lang, update_tax, date_order, packaging, fiscal_position, flag,
+            warehouse_id=warehouse_id, context=context)
+
+        disable_warning = warehouse_id and self.pool['stock.warehouse'].browse(
+            cr, uid, warehouse_id, context).disable_sale_stock_warning or False
+
+        # if not stock warning set in company and warning in res...
+        if res.get('warning', False) and disable_warning:
+            # clean warning
+            warning = {}
+            # call sale_stock module other warning
+            res_packing = self.product_packaging_change(
+                cr, uid, ids, pricelist, product, qty, uom, partner_id,
+                packaging, context=context)
+            res['value'].update(res_packing.get('value', {}))
+            warning_msgs = res_packing.get(
+                'warning') and res_packing['warning']['message'] or ''
+
+            if warning_msgs:
+                warning = {
+                           'title': _('Configuration Error!'),
+                           'message': warning_msgs
+                        }
+            else:
+                # if not sale stock warning_try sale warnings
+                product_change_res = self.product_id_change(
+                    cr, uid, ids, pricelist, product, qty=qty, uom=False,
+                    qty_uos=qty_uos, uos=uos, name=name, partner_id=partner_id,
+                    lang=lang, update_tax=update_tax, date_order=date_order,
+                    packaging=packaging, fiscal_position=fiscal_position,
+                    flag=flag, context=context)
+                warning = product_change_res.get('warning')
+            res.update({'warning': warning})
+        return res
+
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:

BIN
sale_order.pyc


+ 23 - 0
sale_view.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+    <record model="ir.ui.view" id="view_order_stock_form">
+        <field name="name">sale.order.form.inherit</field>
+        <field name="model">sale.order</field>
+        <field name="inherit_id" ref="sale.view_order_form"/>
+        <field name="arch" type="xml">
+            <xpath expr="//field[@name='order_line']/tree/field[@name='product_uom_qty']" position="after">
+                <field name="virtual_available_boolean" groups="sale_stock_availability.see_stock_boolean"/>
+                <field name="virtual_available" groups="sale_stock_availability.see_stock_value"/>
+            </xpath>
+        
+            <xpath expr="//field[@name='order_line']/form//label[@for='product_uos_qty']" position="before">
+                <field name="virtual_available_boolean" groups="sale_stock_availability.see_stock_boolean" attrs="{'invisible':[('state','!=','draft')]}"/>
+                <field name="virtual_available" groups="sale_stock_availability.see_stock_value" attrs="{'invisible':[('state','!=','draft')]}"/>
+            </xpath>  
+        </field>
+    </record>
+
+    </data>
+</openerp>

+ 25 - 0
security/sale_order.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<openerp>
+    <data>
+
+        <record model="ir.module.category" id="module_category_sales_stock">
+            <field name="name">Sales Stock Availability</field>
+            <field name="description">Helps you see stock on quotations.</field>
+            <field name="sequence">2</field>
+        </record>
+
+        <!-- add applications to base groups -->
+        <record model="res.groups" id="see_stock_boolean">
+            <field name="category_id" ref="module_category_sales_stock"/>
+            <field name="name">Only yes/no</field>
+        </record>
+
+        <record model="res.groups" id="see_stock_value">
+            <field name="category_id" ref="module_category_sales_stock"/>
+            <field name="name">Stock Value</field>
+            <!-- No lo podemos agregar porque si es asi va a mostrar los dos campos -->
+            <!-- <field name="implied_ids" eval="[(4, ref('see_stock_boolean'))]"/> -->
+        </record>
+
+    </data>
+</openerp>

+ 12 - 0
stock.py

@@ -0,0 +1,12 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+# For copyright and license notices, see __openerp__.py file in module root
+# directory
+##############################################################################
+from openerp import models, fields
+
+
+class stock_warehouse(models.Model):
+    _inherit = 'stock.warehouse'
+
+    disable_sale_stock_warning = fields.Boolean('Disable Sale Stock Warning')

BIN
stock.pyc


+ 14 - 0
stock_view.xml

@@ -0,0 +1,14 @@
+<openerp>
+    <data>
+        <record model="ir.ui.view" id="view_warehouse">
+            <field name="name">stock.warehouse</field>
+            <field name="model">stock.warehouse</field>
+            <field name="inherit_id" ref="stock.view_warehouse"/>
+            <field name="arch" type="xml">
+                <field name="code" position="after">
+                    <field name="disable_sale_stock_warning"/>
+                </field>
+            </field>
+        </record>
+    </data>
+</openerp>