commit 1cb382fcfd3c1943f9cc9990591a7916d59d3586 Author: Arnis Putniņš Date: Thu Sep 21 21:52:10 2023 +0300 initial commit diff --git a/bb_stock_quant_report/__init__.py b/bb_stock_quant_report/__init__.py new file mode 100755 index 0000000..dc5e6b6 --- /dev/null +++ b/bb_stock_quant_report/__init__.py @@ -0,0 +1,4 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import models diff --git a/bb_stock_quant_report/__manifest__.py b/bb_stock_quant_report/__manifest__.py new file mode 100755 index 0000000..f09492b --- /dev/null +++ b/bb_stock_quant_report/__manifest__.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +{ + 'name': 'Stock Quant Report with Cost, Sale Price and Gross profit', + 'version': '1.0.1', + 'category': 'Stock', + 'icon': '/bb_stock_quant_report/static/description/icon.png', + 'sequence': 20, + 'author': 'Bayarbayasgalan MGL', + 'summary': 'Stock Extra tools', + 'description': """ +This module can show Stock available quantity details with Cost and Sales Price +============================================== +If you want to show Stock Balance with cost and Sale. +You should take Stock Administrator at the user. +Cost is comfortable Average cost and Standard cost. + """, + 'depends': ['stock','product'], + 'data': [ + 'security/bb_stock_security.xml', + 'security/ir.model.access.csv', + 'views/stock_quant_view.xml', + 'views/stock_quant_report_view.xml', + ], + 'qweb': [], + "images": ["static/description/images/stock_quant_report.gif","static/description/images/bb_stock_ss1.png","static/description/images/bb_stock_ss2.png","static/description/images/bb_stock_ss3.png"], + 'website': 'https://www.linkedin.com/in/bayarbayasgalan-jagdal/', + 'installable': True, + 'auto_install': False, + 'license': 'LGPL-3', +} diff --git a/bb_stock_quant_report/i18n/mn.po b/bb_stock_quant_report/i18n/mn.po new file mode 100644 index 0000000..b989487 --- /dev/null +++ b/bb_stock_quant_report/i18n/mn.po @@ -0,0 +1,221 @@ +# Translation of Odoo Server. +# This file contains the translation of the following modules: +# * bb_stock_quant_report +# +msgid "" +msgstr "" +"Project-Id-Version: Odoo Server 15.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2022-12-31 19:15+0000\n" +"PO-Revision-Date: 2022-12-31 19:15+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: bb_stock_quant_report +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.quant_report_search_view +msgid "Available Stock" +msgstr "Үлдэгдэл" + +#. module: bb_stock_quant_report +#: model:ir.actions.act_window,name:bb_stock_quant_report.stock_quant_report_action +#: model:ir.ui.menu,name:bb_stock_quant_report.menu_stock_quant_report +msgid "Balance Details" +msgstr "Үлдэгдэл дэлгэрэнгүй" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__barcode +msgid "Barcode" +msgstr "Баркод" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__categ_id +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.quant_report_search_view +msgid "Category" +msgstr "Ангилал" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__default_code +msgid "Code" +msgstr "Код" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__company_id +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.quant_report_search_view +msgid "Company" +msgstr "Компани" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__display_name +msgid "Display Name" +msgstr "Дэлгэцийн нэр" + +#. module: bb_stock_quant_report +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.quant_report_search_view +msgid "Filters" +msgstr "Шүүлт" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__forecast_quantity +msgid "Future On hand" +msgstr "Ирээдүйн Үлдэгдэл" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__bohir_ashig +msgid "Gross profit" +msgstr "Бохир ашиг" + +#. module: bb_stock_quant_report +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.quant_report_search_view +msgid "Group by..." +msgstr "Бүлэглэх" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__id +msgid "ID" +msgstr "" + +#. module: bb_stock_quant_report +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.view_stock_quant_report_pivot +msgid "Inventory" +msgstr "Агуулах" + +#. module: bb_stock_quant_report +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.view_stock_quant_report_form +msgid "Inventory Valuation" +msgstr "Үлдэгдэл өртөг" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report____last_update +msgid "Last Modified on" +msgstr "Сүүлийн засвар" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__location_id +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.quant_report_search_view +msgid "Location" +msgstr "Байрлал" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__lot_id +msgid "Lot" +msgstr "Цуврал" + +#. module: bb_stock_quant_report +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.quant_report_search_view +msgid "Lot/Serial Number" +msgstr "Цуврал дугаар" + +#. module: bb_stock_quant_report +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.quant_report_search_view +msgid "Negative Stock" +msgstr "Сөрөг Үлдэгдэл" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__quantity +msgid "On hand" +msgstr "Үлдэгдэл" + +#. module: bb_stock_quant_report +#: model:ir.model,name:bb_stock_quant_report.model_product_product +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__product_id +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.quant_report_search_view +msgid "Product" +msgstr "Бараа" + +#. module: bb_stock_quant_report +#: model:ir.model,name:bb_stock_quant_report.model_product_template +msgid "Product Template" +msgstr "Барааны загвар" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__product_tmpl_id +msgid "Product template" +msgstr "Барааны загвар" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__product_uom_id +msgid "Product uom" +msgstr "Хэмжих нэгж" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__qaunt_id +msgid "Quant" +msgstr "Үлдэгдэл баримт" + +#. module: bb_stock_quant_report +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.view_stock_quant_report_form +msgid "Quantity On Hand" +msgstr "Үлдэгдэл" + +#. module: bb_stock_quant_report +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.view_stock_quant_report_form +msgid "Quantity Reserved" +msgstr "Үлдэгдэл Нөөцлөгдсөн" + +#. module: bb_stock_quant_report +#: model:ir.model,name:bb_stock_quant_report.model_stock_quant +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.quant_report_search_view +msgid "Quants" +msgstr "Нөөцийн бүртгэл" + +#. module: bb_stock_quant_report +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.quant_report_search_view +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__reserved_quantity +msgid "Reserved" +msgstr "Нөөцлөгдсөн" + +#. module: bb_stock_quant_report +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.view_stock_quant_report_tree +msgid "SUM" +msgstr "Нийт" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__zarah_negj_price +msgid "Sale unit price" +msgstr "Зарах нэгж үнэ" + +#. module: bb_stock_quant_report +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.stock_quant_report_view_graph +msgid "Stock Quant" +msgstr "Агуулах үлдэгдэл" + +#. module: bb_stock_quant_report +#: model:ir.model,name:bb_stock_quant_report.model_stock_quant_report +msgid "Stock quant report bb" +msgstr "" + +#. module: bb_stock_quant_report +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.quant_report_search_view +msgid "The cost is greater than the sale price" +msgstr "Өртөг зарах үнээс их" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__value_sum +msgid "Total cost" +msgstr "Нийт Өртөг" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__zarah_niit_price +msgid "Total sale price" +msgstr "Нийт зарах үнэ" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__tracking +msgid "Tracking" +msgstr "Мөшгөлт" + +#. module: bb_stock_quant_report +#: model:ir.model.fields,field_description:bb_stock_quant_report.field_stock_quant_report__value +msgid "Unit cost" +msgstr "Нэгж өртөг" + +#. module: bb_stock_quant_report +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.product_template_only_form_view_bb_sq +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.view_stock_quant_tree_editable_inh +#: model_terms:ir.ui.view,arch_db:bb_stock_quant_report.view_stock_quant_report_tree +msgid "View resverve" +msgstr "Нөөцлөлт харах" \ No newline at end of file diff --git a/bb_stock_quant_report/models/__init__.py b/bb_stock_quant_report/models/__init__.py new file mode 100755 index 0000000..d228af2 --- /dev/null +++ b/bb_stock_quant_report/models/__init__.py @@ -0,0 +1,5 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from . import stock_quant +from . import stock_quant_report \ No newline at end of file diff --git a/bb_stock_quant_report/models/stock_quant.py b/bb_stock_quant_report/models/stock_quant.py new file mode 100644 index 0000000..bd181d9 --- /dev/null +++ b/bb_stock_quant_report/models/stock_quant.py @@ -0,0 +1,57 @@ +# -*- coding: utf-8 -*- +from odoo import api, fields, models, tools, modules + +class StockQuant(models.Model): + _inherit = 'stock.quant' + + def view_bb_reserved_quantity(self): + sml_ids = self.env['stock.move.line'].search([ + ('product_id','=',self.product_id.id), + ('location_id','=',self.location_id.id), + ('lot_id','=',self.lot_id.id), + ('state','not in',['done','cancel']), + ('product_qty','>',0) + ]) + return self.view_bb_reserved_quantity_sml(sml_ids) + + def view_bb_reserved_quantity_sml(self, sml_ids): + context = {'create': False, 'edit': False} + tree_view_id = self.env.ref('stock.view_move_line_tree').id + form_view_id = self.env.ref('stock.view_move_line_form').id + action = { + 'name': 'Reserved', + # 'view_mode': 'tree', + 'res_model': 'stock.move.line', + 'views': [(tree_view_id, 'tree'),(form_view_id,'form')], + 'view_id': tree_view_id, + 'domain': [('id','in',sml_ids.ids)], + 'type': 'ir.actions.act_window', + 'context': context, + 'target': 'current' + } + return action + +class ProductTemplate(models.Model): + _inherit = 'product.template' + + + def view_bb_reserved_quantity_mw(self): + sml_ids = self.env['stock.move.line'].search([ + ('product_id','in',self.product_variant_ids.ids), + ('state','not in',['done','cancel']), + ('product_qty','>',0) + ]) + return self.env['stock.quant'].view_bb_reserved_quantity_sml(sml_ids) + +class ProductProduct(models.Model): + _inherit = 'product.product' + + def view_bb_reserved_quantity_mw(self): + sml_ids = self.env['stock.move.line'].search([ + ('product_id','=',self.id), + ('state','not in',['done','cancel']), + ('product_qty','>',0) + ]) + return self.env['stock.quant'].view_bb_reserved_quantity_sml(sml_ids) + + \ No newline at end of file diff --git a/bb_stock_quant_report/models/stock_quant_report.py b/bb_stock_quant_report/models/stock_quant_report.py new file mode 100644 index 0000000..763bbc0 --- /dev/null +++ b/bb_stock_quant_report/models/stock_quant_report.py @@ -0,0 +1,103 @@ +# -*- coding: utf-8 -*- +# Part of Odoo. See LICENSE file for full copyright and licensing details. + +from odoo import api, fields, models, tools + +class StockQuantReport(models.Model): + _name = "stock.quant.report" + _description = "Stock quant report bb" + _auto = False + + qaunt_id = fields.Many2one('stock.quant', 'Quant',readonly=True) + product_id = fields.Many2one('product.product', 'Product',readonly=True) + product_tmpl_id = fields.Many2one('product.template', string='Product template', readonly=True) + categ_id = fields.Many2one('product.category', 'Category', readonly=True) + product_uom_id = fields.Many2one('uom.uom', 'Product uom', readonly=True) + company_id = fields.Many2one('res.company', string='Company', readonly=True) + location_id = fields.Many2one('stock.location', 'Location', readonly=True) + lot_id = fields.Many2one('stock.lot', 'Lot', readonly=True) + quantity = fields.Float('On hand', readonly=True, digits='Product Unit of Measure') + reserved_quantity = fields.Float('Reserved', readonly=True, digits='Product Unit of Measure') + forecast_quantity = fields.Float('Future On hand', readonly=True, digits='Product Unit of Measure') + tracking = fields.Char(string="Tracking", readonly=True) + barcode = fields.Char('Barcode', readonly=True) + default_code = fields.Char('Code', readonly=True) + + + # currency_id = fields.Many2one(related='product_id.currency_id', groups='stock.group_stock_manager') + value = fields.Float(string='Unit cost', groups='stock.group_stock_manager', group_operator='avg') + value_sum = fields.Float(string='Total cost', groups='stock.group_stock_manager') + + zarah_negj_price = fields.Float(string=u'Sale unit price', groups='stock.group_stock_manager') + zarah_niit_price = fields.Float(string=u'Total sale price', groups='stock.group_stock_manager') + bohir_ashig = fields.Float(string=u'Gross profit', groups='stock.group_stock_manager') + + def _select(self): + return """ + SELECT + sq.id as id, + sq.id as qaunt_id, + sq.product_id, + pp.product_tmpl_id, + pt.uom_id as product_uom_id, + sq.company_id, + sq.location_id, + sq.lot_id, + sq.quantity, + sq.reserved_quantity, + sq.quantity-sq.reserved_quantity as forecast_quantity, + pt.tracking, + pp.barcode, + pp.default_code, + pt.categ_id, + ip.value_float as value + ,sq.quantity*ip.value_float as value_sum + ,pt.list_price as zarah_negj_price + ,sq.quantity*pt.list_price as zarah_niit_price + ,(sq.quantity*pt.list_price)-(sq.quantity*ip.value_float) as bohir_ashig + """ + + def _from(self): + return """ + FROM stock_quant AS sq + LEFT JOIN product_product pp ON (pp.id=sq.product_id) + LEFT JOIN product_template pt ON (pp.product_tmpl_id=pt.id) + LEFT JOIN stock_location sl ON (sl.id=sq.location_id) + LEFT JOIN ir_property as ip on (ip.res_id = 'product.product,'||sq.product_id and ip.name = 'standard_price' and sq.company_id=ip.company_id) + """ + + def _group_by(self): + return """ + + """ + + def _having(self): + return """ + + """ + + def _where(self): + return """""" + + def init(self): + tools.drop_view_if_exists(self._cr, self._table) + self._cr.execute(""" + CREATE OR REPLACE VIEW %s AS ( + %s + %s + %s + %s + %s + ) + """ % (self._table, self._select(), self._from(), self._where(), self._group_by(),self._having()) + ) + + def view_bb_reserved_quantity(self): + sml_ids = self.env['stock.move.line'].search([ + ('product_id','=',self.product_id.id), + ('location_id','=',self.location_id.id), + ('lot_id','=',self.lot_id.id), + ('state','not in',['done','cancel']), + ('product_qty','>',0) + ]) + return self.env['stock.quant'].view_bb_reserved_quantity_sml(sml_ids) \ No newline at end of file diff --git a/bb_stock_quant_report/security/bb_stock_security.xml b/bb_stock_quant_report/security/bb_stock_security.xml new file mode 100755 index 0000000..9150744 --- /dev/null +++ b/bb_stock_quant_report/security/bb_stock_security.xml @@ -0,0 +1,13 @@ + + + + + + stock_quant_report multi-company + + + ['|',('company_id','=',False),('company_id', 'in', company_ids)] + + + + diff --git a/bb_stock_quant_report/security/ir.model.access.csv b/bb_stock_quant_report/security/ir.model.access.csv new file mode 100755 index 0000000..e96f3af --- /dev/null +++ b/bb_stock_quant_report/security/ir.model.access.csv @@ -0,0 +1,3 @@ +id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink + +access_stock_quant_report_user,stock.quant.report,bb_stock_quant_report.model_stock_quant_report,stock.group_stock_user,1,1,1,1 diff --git a/bb_stock_quant_report/static/description/icon.png b/bb_stock_quant_report/static/description/icon.png new file mode 100644 index 0000000..5e88ce6 Binary files /dev/null and b/bb_stock_quant_report/static/description/icon.png differ diff --git a/bb_stock_quant_report/static/description/images/bb_stock_ss1.png b/bb_stock_quant_report/static/description/images/bb_stock_ss1.png new file mode 100644 index 0000000..2c1a8c1 Binary files /dev/null and b/bb_stock_quant_report/static/description/images/bb_stock_ss1.png differ diff --git a/bb_stock_quant_report/static/description/images/bb_stock_ss2.png b/bb_stock_quant_report/static/description/images/bb_stock_ss2.png new file mode 100644 index 0000000..3667f1e Binary files /dev/null and b/bb_stock_quant_report/static/description/images/bb_stock_ss2.png differ diff --git a/bb_stock_quant_report/static/description/images/bb_stock_ss3.png b/bb_stock_quant_report/static/description/images/bb_stock_ss3.png new file mode 100644 index 0000000..5e3930b Binary files /dev/null and b/bb_stock_quant_report/static/description/images/bb_stock_ss3.png differ diff --git a/bb_stock_quant_report/static/description/images/stock_quant_report.gif b/bb_stock_quant_report/static/description/images/stock_quant_report.gif new file mode 100644 index 0000000..e2d6c22 Binary files /dev/null and b/bb_stock_quant_report/static/description/images/stock_quant_report.gif differ diff --git a/bb_stock_quant_report/static/description/index.html b/bb_stock_quant_report/static/description/index.html new file mode 100644 index 0000000..16b0d1b --- /dev/null +++ b/bb_stock_quant_report/static/description/index.html @@ -0,0 +1,58 @@ + + +
+
+

This module can display the following:

+
+
+ +
+
+
+

Features

+
+
    +
  • + + Usefull and Analyze columns +
  • +
  • + + Show stock quantity with cost and sale price +
  • +
  • + + Free module +
  • +
+
+
+
+
+
+

If you want to show Stock Balance with cost and Sale.

+ +
+
+

Usefull and Analyze columns. Cost, Sale price and Gross profit

+ +
+ +
+

You should take Stock Administrator at the user.

+ +
+ + +
+
+ +
+
\ No newline at end of file diff --git a/bb_stock_quant_report/views/stock_quant_report_view.xml b/bb_stock_quant_report/views/stock_quant_report_view.xml new file mode 100644 index 0000000..94a72e3 --- /dev/null +++ b/bb_stock_quant_report/views/stock_quant_report_view.xml @@ -0,0 +1,133 @@ + + + + stock.quant.report.search + stock.quant.report + + + + + + + + + + + + + + + + + + + + + + + + + + stock.quant.report.form + stock.quant.report + + +
+ + + + + + + + + + + +
+
+
+ + + stock.quant.report.tree + stock.quant.report + + + + + + + + + + + + + + + + + + + + + + + + + + + + +