Browse Source

[FIX] Bug Fixed 'export_stockinfo_xls'

pull/134/merge
Ajmalcybrosys 6 years ago
parent
commit
75dfef7174
  1. 2
      export_stockinfo_xls/README.rst
  2. 4
      export_stockinfo_xls/__manifest__.py
  3. 2
      export_stockinfo_xls/controllers/main.py
  4. 12
      export_stockinfo_xls/doc/RELEASE_NOTES.md
  5. 52
      export_stockinfo_xls/models/wizard.py
  6. BIN
      export_stockinfo_xls/static/description/banner.jpg
  7. BIN
      export_stockinfo_xls/static/description/banner.png
  8. BIN
      export_stockinfo_xls/static/description/icon.png
  9. 19
      export_stockinfo_xls/views/wizard_view.xml

2
export_stockinfo_xls/README.rst

@ -1,4 +1,4 @@
Export Product Stock in Excel v12 Export Product Stock in Excel v13
================================= =================================
This module helps you to take current stock report for all products in each warehouse. This module helps you to take current stock report for all products in each warehouse.

4
export_stockinfo_xls/__manifest__.py

@ -22,7 +22,7 @@
{ {
'name': 'Export Product Stock in Excel', 'name': 'Export Product Stock in Excel',
'version': '13.0.1.0.0', 'version': '13.0.1.1.0',
'summary': "Current Stock Report for all Products in each Warehouse", 'summary': "Current Stock Report for all Products in each Warehouse",
'description': "Current Stock Report for all Products in each Warehouse, Odoo 13,Odoo13", 'description': "Current Stock Report for all Products in each Warehouse, Odoo 13,Odoo13",
'category': 'Warehouse', 'category': 'Warehouse',
@ -40,7 +40,7 @@
'views/wizard_view.xml', 'views/wizard_view.xml',
'views/action_manager.xml', 'views/action_manager.xml',
], ],
'images': ['static/description/banner.jpg'], 'images': ['static/description/banner.png'],
'license': 'AGPL-3', 'license': 'AGPL-3',
'installable': True, 'installable': True,
'auto_install': False, 'auto_install': False,

2
export_stockinfo_xls/controllers/main.py

@ -32,7 +32,7 @@ class XLSXReportController(http.Controller):
@http.route('/xlsx_reports', type='http', auth='user', methods=['POST'], csrf=False) @http.route('/xlsx_reports', type='http', auth='user', methods=['POST'], csrf=False)
def get_report_xlsx(self, model, options, output_format, token, report_name, **kw): def get_report_xlsx(self, model, options, output_format, token, report_name, **kw):
uid = request.session.uid uid = request.session.uid
report_obj = request.env[model].sudo(uid) report_obj = request.env[model].with_user(uid)
options = json.loads(options) options = json.loads(options)
try: try:
if output_format == 'xlsx': if output_format == 'xlsx':

12
export_stockinfo_xls/doc/RELEASE_NOTES.md

@ -2,8 +2,16 @@
#### 01.11.2019 #### 01.11.2019
#### Version 13.0.1.0.0 #### Version 13.0.1.0.0
#### Migration #### ADD
Migration Of Export Product Stock in Excel Initial Commit Export Product Stock in Excel
#### 05.12.2019
#### Version 13.0.1.1.0
#### FIX
Updation Of Export Product Stock in Excel

52
export_stockinfo_xls/models/wizard.py

@ -19,18 +19,12 @@
# If not, see <http://www.gnu.org/licenses/>. # If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################# #############################################################################
from datetime import datetime
from datetime import date, datetime from datetime import date, datetime
from odoo import models, fields, api
import time
import pytz import pytz
import json import json
import datetime import datetime
import io import io
from odoo import api, fields, models, _ from odoo import api, fields, models, _
from odoo.exceptions import UserError
from odoo.exceptions import ValidationError
from odoo.tools import date_utils from odoo.tools import date_utils
try: try:
from odoo.tools.misc import xlsxwriter from odoo.tools.misc import xlsxwriter
@ -46,26 +40,12 @@ class StockReport(models.TransientModel):
category = fields.Many2many('product.category', 'categ_wiz_rel', 'categ', 'wiz', string='Warehouse') category = fields.Many2many('product.category', 'categ_wiz_rel', 'categ', 'wiz', string='Warehouse')
def export_xls(self): def export_xls(self):
# context = self._context
# data = {'ids': context.get('active_ids', [])}
# data['model'] = 'wizard.stock.history'
# data['form'] = self.read()[0]
# for field in data['form'].keys():
# if isinstance(data['form'][field], tuple):
# data['form'][field] = data['form'][field][0]
# if context.get('xls_export'):
# return self.env.ref('export_stockinfo_xls.stock_xlsx').report_action(self, data=datas)
data = { data = {
'ids': self.ids, 'ids': self.ids,
'model': self._name, 'model': self._name,
'warehouse': self.warehouse.id, 'warehouse': self.warehouse.ids,
'category': self.category.id, 'category': self.category.ids,
# 'date_start': self.date_start,
# 'date_end': self.date_end,
# 'state': self.state,
# 'product_id': self.product_id.id,
# 'usage': self.usage,
} }
return { return {
'type': 'ir_actions_xlsx_download', 'type': 'ir_actions_xlsx_download',
@ -107,9 +87,10 @@ class StockReport(models.TransientModel):
('order_id.picking_type_id', '=', warehouse)]) ('order_id.picking_type_id', '=', warehouse)])
for i in purchase_obj: for i in purchase_obj:
purchase_value = purchase_value + i.product_qty purchase_value = purchase_value + i.product_qty
available_qty = product.with_context({'warehouse': warehouse}).virtual_available + \ test = product.with_context(warehouse=warehouse)._compute_quantities()
product.with_context({'warehouse': warehouse}).outgoing_qty - \ available_qty = product.virtual_available + \
product.with_context({'warehouse': warehouse}).incoming_qty product.outgoing_qty - \
product.incoming_qty
value = available_qty * product.standard_price value = available_qty * product.standard_price
vals = { vals = {
'sku': product.default_code, 'sku': product.default_code,
@ -126,21 +107,16 @@ class StockReport(models.TransientModel):
'purchase_value': purchase_value, 'purchase_value': purchase_value,
} }
lines.append(vals) lines.append(vals)
print(lines)
return lines return lines
def get_xlsx_report(self, data, response): def get_xlsx_report(self, data, response):
output = io.BytesIO() output = io.BytesIO()
workbook = xlsxwriter.Workbook(output, {'in_memory': True}) workbook = xlsxwriter.Workbook(output, {'in_memory': True})
lines = self.browse(data['ids']) lines = self.browse(data['ids'])
print("lines",lines)
d = lines.category d = lines.category
get_warehouse = self.get_warehouse(lines) get_warehouse = self.get_warehouse(lines)
print("get_warehouse",get_warehouse)
count = len(get_warehouse[0]) * 11 + 6 count = len(get_warehouse[0]) * 11 + 6
print("count",count)
comp = self.env.user.company_id.name comp = self.env.user.company_id.name
print("comp",comp)
sheet = workbook.add_worksheet('Stock Info') sheet = workbook.add_worksheet('Stock Info')
format0 = workbook.add_format({'font_size': 20, 'align': 'center', 'bold': True}) format0 = workbook.add_format({'font_size': 20, 'align': 'center', 'bold': True})
format1 = workbook.add_format({'font_size': 14, 'align': 'vcenter', 'bold': True}) format1 = workbook.add_format({'font_size': 14, 'align': 'vcenter', 'bold': True})
@ -171,11 +147,10 @@ class StockReport(models.TransientModel):
sheet.merge_range(4, 2, 4, 3 + len(d1), cat, format4) sheet.merge_range(4, 2, 4, 3 + len(d1), cat, format4)
sheet.merge_range(5, 0, 5, 1, 'Warehouse(s) : ', format4) sheet.merge_range(5, 0, 5, 1, 'Warehouse(s) : ', format4)
w_house = w_house.join(get_warehouse[0]) w_house = w_house.join(get_warehouse[0])
sheet.merge_range(5, 2, 5, 3+len(get_warehouse[0]), w_house, format4) sheet.merge_range(5, 2, 5, 3 + len(get_warehouse[0]), w_house, format4)
user = self.env['res.users'].browse(self.env.uid) user = self.env['res.users'].browse(self.env.uid)
tz = pytz.timezone(user.tz) tz = pytz.timezone(user.tz)
time = pytz.utc.localize(datetime.datetime.now()).astimezone(tz) time = pytz.utc.localize(datetime.datetime.now()).astimezone(tz)
# print("tz", time)
sheet.merge_range('A8:G8', 'Report Date: ' + str(time.strftime("%Y-%m-%d %H:%M %p")), format1) sheet.merge_range('A8:G8', 'Report Date: ' + str(time.strftime("%Y-%m-%d %H:%M %p")), format1)
sheet.merge_range(7, 7, 7, count, 'Warehouses', format1) sheet.merge_range(7, 7, 7, count, 'Warehouses', format1)
sheet.merge_range('A9:G9', 'Product Information', format11) sheet.merge_range('A9:G9', 'Product Information', format11)
@ -236,14 +211,15 @@ class StockReport(models.TransientModel):
sheet.merge_range(prod_row, prod_col + 4, prod_row, prod_col + 5, each['net_on_hand'], red_mark) sheet.merge_range(prod_row, prod_col + 4, prod_row, prod_col + 5, each['net_on_hand'], red_mark)
else: else:
sheet.merge_range(prod_row, prod_col + 4, prod_row, prod_col + 5, each['net_on_hand'], font_size_8) sheet.merge_range(prod_row, prod_col + 4, prod_row, prod_col + 5, each['net_on_hand'], font_size_8)
if each['sale_value'] < 0: if each['sale_value'] < 0:
sheet.merge_range(prod_row, prod_col + 6, prod_row, prod_col + 7, each['sale_value'], red_mark) sheet.merge_range(prod_row, prod_col + 6, prod_row, prod_col + 7, each['sale_value'], red_mark)
else: else:
sheet.merge_range(prod_row, prod_col + 6, prod_row, prod_col + 7, each['sale_value'], font_size_8) sheet.merge_range(prod_row, prod_col + 6, prod_row, prod_col + 7, each['sale_value'], font_size_8)
if each['purchase_value'] < 0: if each['purchase_value'] < 0:
sheet.merge_range(prod_row, prod_col + 8, prod_row, prod_col + 9, each['purchase_value'], red_mark) sheet.merge_range(prod_row, prod_col + 8, prod_row, prod_col + 9, each['purchase_value'], red_mark)
else: else:
sheet.merge_range(prod_row, prod_col + 8, prod_row, prod_col + 9, each['purchase_value'], font_size_8) sheet.merge_range(prod_row, prod_col + 8, prod_row, prod_col + 9, each['purchase_value'],
font_size_8)
if each['total_value'] < 0: if each['total_value'] < 0:
sheet.write(prod_row, prod_col + 10, each['total_value'], red_mark) sheet.write(prod_row, prod_col + 10, each['total_value'], red_mark)
else: else:

BIN
export_stockinfo_xls/static/description/banner.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

BIN
export_stockinfo_xls/static/description/banner.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 KiB

BIN
export_stockinfo_xls/static/description/icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 37 KiB

19
export_stockinfo_xls/views/wizard_view.xml

@ -38,15 +38,6 @@
<field name="target">new</field> <field name="target">new</field>
</record> </record>
<!-- <report-->
<!-- id="stock_xlsx"-->
<!-- model="wizard.stock.history"-->
<!-- string="Product Stock Info"-->
<!-- report_type="xlsx"-->
<!-- name="export_stockinfo_xls.stock_report_xls.xlsx"-->
<!-- file="export_stockinfo_xls.stock_report_xls.xlsx"-->
<!-- menu="False"-->
<!-- attachment_use="False"/>-->
<menuitem name="Current stock in Excel" <menuitem name="Current stock in Excel"
parent="stock.menu_warehouse_report" parent="stock.menu_warehouse_report"
@ -54,13 +45,5 @@
action="wizard_act" action="wizard_act"
sequence="3"/> sequence="3"/>
</data> </data>
<!-- <record id="action_stock_move_report_wizard" model="ir.actions.act_window">-->
<!-- <field name="name">Stock Move Report Report</field>-->
<!-- <field name="res_model">stock.moves.report.wizard</field>-->
<!-- <field name="type">ir.actions.act_window</field>-->
<!-- <field name="view_mode">form</field>-->
<!-- <field name="view_id" ref="stock_move_report_wizard_view"/>-->
<!-- <field name="target">new</field>-->
<!-- </record>-->
<!-- <menuitem id="stock_move_report_child_menu" name="Stock Move Report" action="action_stock_move_report_wizard" parent="stock.menu_warehouse_report"/>-->
</odoo> </odoo>

Loading…
Cancel
Save