add categories to printer order
This commit is contained in:
parent
9d364b04c2
commit
aaf52741b4
|
@ -41,6 +41,7 @@ def register():
|
|||
shop.SaleDiscont,
|
||||
shop.SaleShopDiscounts,
|
||||
printer.POSPrinter,
|
||||
printer.POSPrinterCategory,
|
||||
sale.SaleSquareBoxStart,
|
||||
statement.Statement,
|
||||
statement.MultiPaymentDeliveryStart,
|
||||
|
|
17
printer.py
17
printer.py
|
@ -13,12 +13,27 @@ class POSPrinter(ModelSQL, ModelView):
|
|||
('network', 'Network'),
|
||||
('ssh', 'SSH'),
|
||||
('cups', 'Cups'),
|
||||
],'Interface', select=True)
|
||||
], 'Interface', select=True)
|
||||
host = fields.Char('Host', select=True)
|
||||
port = fields.Char('Port')
|
||||
row_characters = fields.Integer('Row Characters')
|
||||
categories = fields.One2Many('sale.pos_printer.category', 'printer', 'Categories')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(POSPrinter, cls).__setup__()
|
||||
cls._order.insert(0, ('name', 'ASC'))
|
||||
|
||||
|
||||
class POSPrinterCategory(ModelSQL, ModelView):
|
||||
"POS Printer Category"
|
||||
__name__ = "sale.pos_printer.category"
|
||||
|
||||
printer = fields.Many2One("sale.pos_printer", 'Printer')
|
||||
category = fields.Many2One("product.category", 'Category')
|
||||
sequence = fields.Char('Secuence')
|
||||
|
||||
@classmethod
|
||||
def __setup__(cls):
|
||||
super(POSPrinterCategory, cls).__setup__()
|
||||
cls._order.insert(0, ('sequence', 'ASC'))
|
10
printer.xml
10
printer.xml
|
@ -46,6 +46,16 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="perm_create" eval="True"/>
|
||||
<field name="perm_delete" eval="True"/>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="pos_printer_category_view_tree">
|
||||
<field name="model">sale.pos_printer.category</field>
|
||||
<field name="type">tree</field>
|
||||
<field name="name">pos_printer_category_tree</field>
|
||||
</record>
|
||||
<record model="ir.ui.view" id="pos_printer_category_view_form">
|
||||
<field name="model">sale.pos_printer.category</field>
|
||||
<field name="type">form</field>
|
||||
<field name="name">pos_printer_category_form</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</tryton>
|
||||
|
|
25
sale.py
25
sale.py
|
@ -333,8 +333,12 @@ class Sale(metaclass=PoolMeta):
|
|||
'payment_term': payment_term.name if payment_term else '',
|
||||
'total_amount': sale.total_amount_cache or str(sale.total_amount),
|
||||
'shop': shop_name,
|
||||
'lines': [],
|
||||
}
|
||||
if printer.categories:
|
||||
orders[printer_id]['lines'] = {c.sequence: [] for c in printer.categories}
|
||||
orders[printer_id]['categories'] = {c.category.id:c.sequence for c in printer.categories}
|
||||
else:
|
||||
orders[printer_id]['lines'] = []
|
||||
if hasattr(sale, 'kind'):
|
||||
orders[printer_id]['kind'] = sale.kind or ','
|
||||
if hasattr(sale, 'table_assigned'):
|
||||
|
@ -342,12 +346,25 @@ class Sale(metaclass=PoolMeta):
|
|||
extras = cls.get_extras(sale)
|
||||
if extras:
|
||||
orders[printer_id].update(extras)
|
||||
orders[printer_id]['lines'].append({
|
||||
value_line = {
|
||||
'name': template.name,
|
||||
'quantity': str(qty),
|
||||
'unit_price': int(unit_price),
|
||||
'note': notes,
|
||||
})
|
||||
}
|
||||
if isinstance(orders[printer_id]['lines'], list):
|
||||
orders[printer_id]['lines'].append(value_line)
|
||||
else:
|
||||
key_id = orders[printer_id]['categories'][template.categories[0].id]
|
||||
try:
|
||||
orders[printer_id]['lines'][key_id].append(value_line)
|
||||
except Exception:
|
||||
orders[printer_id]['lines'][key_id] = [value_line]
|
||||
|
||||
for order in orders.values():
|
||||
if isinstance(order['lines'], dict):
|
||||
order['lines'] = [line for cats in order['lines'].values() for line in cats]
|
||||
|
||||
print('orders return', orders)
|
||||
return orders
|
||||
|
||||
|
@ -1642,7 +1659,7 @@ class SaleLine(metaclass=PoolMeta):
|
|||
__name__ = 'sale.line'
|
||||
order_sended = fields.Boolean('Order Sended')
|
||||
qty_fraction = fields.Char('Qty Fraction')
|
||||
|
||||
|
||||
@staticmethod
|
||||
def default_quantity():
|
||||
return 1
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[tryton]
|
||||
version=6.0.5
|
||||
version=6.0.6
|
||||
depends:
|
||||
product
|
||||
account
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<form >
|
||||
<label name="sequence"/>
|
||||
<field name="sequence"/>
|
||||
<label name="printer"/>
|
||||
<field name="printer"/>
|
||||
<label name="category"/>
|
||||
<field name="category"/>
|
||||
</form>
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||
this repository contains the full copyright notices and license terms. -->
|
||||
<tree>
|
||||
<field name="sequence"/>
|
||||
<field name="printer"/>
|
||||
<field name="category"/>
|
||||
</tree>
|
|
@ -14,4 +14,5 @@ this repository contains the full copyright notices and license terms. -->
|
|||
<field name="port"/>
|
||||
<label name="row_characters"/>
|
||||
<field name="row_characters"/>
|
||||
<field name="categories" colspan="4" view_ids="sale_pos_frontend.pos_printer_category_view_tree,sale_pos_frontend.pos_printer_category_view_form"/>
|
||||
</form>
|
||||
|
|
Loading…
Reference in New Issue