add report delete products for sales
This commit is contained in:
parent
f9097665ca
commit
d05139e942
|
@ -19,6 +19,8 @@ def register():
|
|||
sale.Sale,
|
||||
sale.SaleForceDraft,
|
||||
sale.SaleLine,
|
||||
sale.SaleLineHistoryDelete,
|
||||
sale.SaleLineHistoryDeleteStart,
|
||||
sale.SaleMove,
|
||||
shop.SaleShop,
|
||||
production.Production,
|
||||
|
@ -29,7 +31,9 @@ def register():
|
|||
module='sale_pos_frontend_rest', type_='model')
|
||||
Pool.register(
|
||||
sale.SaleSquareBoxGlobal,
|
||||
sale.SaleLineHistoryDeleteWizard,
|
||||
module='sale_pos_frontend_rest', type_='wizard')
|
||||
Pool.register(
|
||||
sale.SaleSquareBoxGlobalReport,
|
||||
sale.SaleLineHistoryDeleteReport,
|
||||
module='sale_pos_frontend_rest', type_='report')
|
||||
|
|
File diff suppressed because it is too large
Load Diff
126
sale.py
126
sale.py
|
@ -4,10 +4,13 @@ from __future__ import unicode_literals
|
|||
from datetime import date, datetime
|
||||
from sql import Table
|
||||
from trytond.pool import PoolMeta, Pool
|
||||
from trytond.model import fields, ModelSQL
|
||||
from trytond.model import fields, ModelSQL, ModelView
|
||||
from trytond.modules.product import price_digits
|
||||
from trytond.pyson import Eval
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.wizard import Wizard
|
||||
from trytond.wizard import (
|
||||
Wizard, StateTransition, StateView, Button, StateReport
|
||||
)
|
||||
from decimal import Decimal
|
||||
from trytond.wizard import StateReport
|
||||
from trytond.report import Report
|
||||
|
@ -81,7 +84,6 @@ class Sale(metaclass=PoolMeta):
|
|||
if tables:
|
||||
ShopTable.write(tables, {'sale': None, 'state':'available'})
|
||||
|
||||
|
||||
@classmethod
|
||||
def transition_pay_(cls, sales_to_pay):
|
||||
pool = Pool()
|
||||
|
@ -314,6 +316,124 @@ class SaleLine(metaclass=PoolMeta):
|
|||
__name__ = 'sale.line'
|
||||
production = fields.Many2One('production', 'Production')
|
||||
|
||||
@classmethod
|
||||
def delete(cls, lines):
|
||||
HistoryDelete = Pool().get('sale.line._history.delete')
|
||||
lines_to_create = []
|
||||
lines_to_create_append = lines_to_create.append
|
||||
for line in lines:
|
||||
if line.order_sended:
|
||||
value = {
|
||||
'line_id': line.id,
|
||||
'product': line.product,
|
||||
'quantity': line.quantity,
|
||||
'date': line.sale.sale_date,
|
||||
'order_status': line.sale.order_status,
|
||||
'sale_state': line.sale.state,
|
||||
'unit_price': line.unit_price,
|
||||
'base_price': line.base_price,
|
||||
'shop': line.sale.shop
|
||||
}
|
||||
lines_to_create_append(value)
|
||||
super(SaleLine, cls).delete(lines)
|
||||
if lines_to_create:
|
||||
HistoryDelete.create(lines_to_create)
|
||||
|
||||
|
||||
class SaleLineHistoryDelete(ModelView, ModelSQL):
|
||||
'Sale Line History Delete'
|
||||
__name__ = 'sale.line._history.delete'
|
||||
|
||||
product = fields.Many2One('product.product', 'Product')
|
||||
line_id = fields.Char('Line id')
|
||||
order_status = fields.Char('Order Status')
|
||||
sale_state = fields.Char('Sale State')
|
||||
quantity = fields.Float('Quantity',
|
||||
digits=(16, Eval('unit_digits', 2)))
|
||||
shop = fields.Many2One('sale.shop', 'Shop')
|
||||
unit_price = fields.Numeric('Unit Price', digits=price_digits)
|
||||
date = fields.Date('Date')
|
||||
base_price = fields.Numeric('Base Price', digits=price_digits)
|
||||
|
||||
|
||||
class SaleLineHistoryDeleteStart(ModelSQL, ModelView):
|
||||
'Sale Line History Delete Start'
|
||||
__name__ = 'line_history.delete_start'
|
||||
|
||||
company = fields.Many2One('company.company', 'Company', required=True)
|
||||
start_date = fields.Date('Date', required=True)
|
||||
end_date = fields.Date('Date', required=True)
|
||||
shop = fields.Many2One('sale.shop', 'Shop', required=True)
|
||||
|
||||
@staticmethod
|
||||
def default_company():
|
||||
return Transaction().context.get('company')
|
||||
|
||||
@staticmethod
|
||||
def default_shop():
|
||||
return Transaction().context.get('shop')
|
||||
|
||||
@staticmethod
|
||||
def default_end_date():
|
||||
Date = Pool().get('ir.date')
|
||||
return Date.today()
|
||||
|
||||
@staticmethod
|
||||
def default_start_date():
|
||||
Date = Pool().get('ir.date')
|
||||
today = Date.today()
|
||||
date_ = date(today.year, today.month, 1)
|
||||
return date_
|
||||
|
||||
|
||||
class SaleLineHistoryDeleteWizard(Wizard):
|
||||
'Sale Line History Delete'
|
||||
__name__ = 'line_history.delete_wizard'
|
||||
|
||||
start = StateView('line_history.delete_start',
|
||||
'sale_pos_frontend_rest.line_history_delete_view_form', [
|
||||
Button('Cancel', 'end', 'tryton-cancel'),
|
||||
Button('Print', 'print_', 'tryton-ok', default=True),
|
||||
])
|
||||
print_ = StateReport('line_history.delete_report')
|
||||
|
||||
def do_print_(self, action):
|
||||
report_context = {
|
||||
'company': self.start.company.id,
|
||||
'start_date': self.start.start_date,
|
||||
'end_date': self.start.end_date,
|
||||
'shop': self.start.shop.id,
|
||||
}
|
||||
return action, report_context
|
||||
|
||||
def transition_print_(self):
|
||||
return 'end'
|
||||
|
||||
|
||||
class SaleLineHistoryDeleteReport(Report):
|
||||
'Sale Line History Delete Report'
|
||||
__name__ = 'line_history.delete_report'
|
||||
|
||||
@classmethod
|
||||
def get_context(cls, records, header, data):
|
||||
report_context = super().get_context(records, header, data)
|
||||
pool = Pool()
|
||||
History = pool.get('sale.line._history.delete')
|
||||
Company = pool.get('company.company')
|
||||
Shop = pool.get('sale.shop')
|
||||
domain = [
|
||||
('date', '>=', data['start_date']),
|
||||
('date', '<=', data['end_date']),
|
||||
]
|
||||
records = History.search_read(domain)
|
||||
record_ids = [r['id'] for r in records]
|
||||
records = cls._get_records(record_ids, 'sale.line._history.delete', data)
|
||||
company = Company(data['company'])
|
||||
report_context['company'] = company
|
||||
report_context['shop_name'] = Shop.name
|
||||
report_context['records'] = records
|
||||
return report_context
|
||||
|
||||
|
||||
class SaleSquareBoxGlobal(SaleSquareBox):
|
||||
'Sale Square Box Global'
|
||||
|
|
21
sale.xml
21
sale.xml
|
@ -36,5 +36,26 @@ The COPYRIGHT file at the top level of this repository contains the full copyrig
|
|||
id="menu_sale_square_box_global" icon="tryton-print"
|
||||
action="wizard_print_sale_square_box_global" sequence="100"/>
|
||||
|
||||
<record model="ir.action.report" id="report_history_delete_product">
|
||||
<field name="name">Report History Delete Product</field>
|
||||
<field name="model"></field>
|
||||
<field name="report_name">line_history.delete_report</field>
|
||||
<field name="report">sale_pos_frontend_rest/history_delete_product.fods</field>
|
||||
<field name="template_extension">ods</field>
|
||||
<field name="translatable">False</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="line_history_delete_view_form">
|
||||
<field name="model">line_history.delete_start</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">line_history_delete_view_form</field>
|
||||
</record>
|
||||
<record model="ir.action.wizard" id="wizard_print_history_delete_product">
|
||||
<field name="name">History Delete Products</field>
|
||||
<field name="wiz_name">line_history.delete_wizard</field>
|
||||
</record>
|
||||
<menuitem parent="sale.menu_reporting"
|
||||
id="menu_sale_history_delete_product" icon="tryton-print"
|
||||
action="wizard_print_history_delete_product"/>
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
2
setup.py
2
setup.py
|
@ -76,7 +76,7 @@ setup(name=name,
|
|||
],
|
||||
package_data={
|
||||
'trytond.modules.%s' % MODULE: (info.get('xml', [])
|
||||
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.odt', '*.ods']),
|
||||
+ ['tryton.cfg', 'view/*.xml', 'locale/*.po', '*.odt', '*.ods', '*.fodt', '*.fods']),
|
||||
},
|
||||
classifiers=[
|
||||
'Development Status :: 5 - Production/Stable',
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part sale_shop module for Tryton.
|
||||
The COPYRIGHT file at the top level of this repository contains the full copyright notices and license terms. -->
|
||||
<form>
|
||||
<label name="company"/>
|
||||
<field name="company"/>
|
||||
<label name="shop"/>
|
||||
<field name="shop"/>
|
||||
<label name="start_date"/>
|
||||
<field name="start_date"/>
|
||||
<label name="end_date"/>
|
||||
<field name="end_date"/>
|
||||
</form>
|
Loading…
Reference in New Issue