finish bill ticket
This commit is contained in:
parent
7b244fa0da
commit
2ab5993a90
59
sale.py
59
sale.py
@ -27,14 +27,41 @@ class Sale(metaclass=PoolMeta):
|
||||
def default_pizza_number(cls):
|
||||
return 0
|
||||
|
||||
def get_invoice_resolution(subtype):
|
||||
if subtype:
|
||||
resolution = subtype.sequence.invoice_resolution
|
||||
if resolution:
|
||||
return dict([('resolution_number', resolution.resolution_number),
|
||||
('resolution_prefix', resolution.prefix),
|
||||
('valid_date_time_from', str(resolution.valid_date_time_from)),
|
||||
('valid_date_time_to', str(resolution.valid_date_time_to)),
|
||||
('from_number', resolution.from_number),
|
||||
('to_number', resolution.to_number)])
|
||||
|
||||
@classmethod
|
||||
def get_invoice(cls, record):
|
||||
pool = Pool()
|
||||
ctx = Transaction().context
|
||||
Shop = pool.get('sale.shop')
|
||||
shop = Shop.search([('id', '=', ctx["shop"])])[0]
|
||||
if record.state != 'draft' and record.invoices:
|
||||
invoice = record.invoices[0]
|
||||
data = {}
|
||||
data['invoice_number'] = invoice.number
|
||||
subtype = invoice.subtype
|
||||
#raise UserError(str(subtype))
|
||||
data['resolution'] = cls.get_invoice_resolution(subtype)
|
||||
|
||||
def report_bill(records):
|
||||
return data
|
||||
|
||||
@classmethod
|
||||
def report_bill(cls, records):
|
||||
if not records:
|
||||
return
|
||||
|
||||
pool = Pool()
|
||||
ctx = Transaction().context
|
||||
report = records[0]
|
||||
record = records[0]
|
||||
User = pool.get('res.user')
|
||||
Shop = pool.get('sale.shop')
|
||||
data = {}
|
||||
@ -43,24 +70,30 @@ class Sale(metaclass=PoolMeta):
|
||||
data["shop_name"] = shop.name
|
||||
data["shop_address"] = shop.address.street
|
||||
data["user"] = user.name
|
||||
data["party"] = report.party.name
|
||||
data["tax_identifier_type"] = report.party.tax_identifier.type_string
|
||||
data["tax_identifier_code"] = report.party.tax_identifier.code
|
||||
data["address"] = report.invoice_address.street
|
||||
data["city"] = report.invoice_address.subdivision_municipality.name
|
||||
data["zone"] = report.zone.name if report.zone else ""
|
||||
data["table"] = report.table.name if report.table else ""
|
||||
data['invoice'] = cls.get_invoice(record)
|
||||
data["party"] = record.party.name
|
||||
data["tax_identifier_type"] = record.party.tax_identifier.type_string
|
||||
data["tax_identifier_code"] = record.party.tax_identifier.code
|
||||
data["address"] = record.invoice_address.street
|
||||
data["city"] = record.invoice_address.subdivision_municipality.name
|
||||
data["zone"] = record.zone.name if record.zone else ""
|
||||
data["table"] = record.table.name if record.table else ""
|
||||
data["lines"] = [{'type': line.type,
|
||||
"product": line.product.name if line.type != 'title' else None,
|
||||
"quantity": line.quantity if line.type != 'title' else None,
|
||||
"uom": line.unit.symbol if line.type != 'title' else None,
|
||||
"unit_price": str(line.unit_price) if line.type != 'title' else None,
|
||||
"taxes": str(round(line.taxes[0].rate * 100, 2))+'%' if line.type != 'title' and line.taxes else None
|
||||
} for line in report.lines]
|
||||
} for line in record.lines]
|
||||
|
||||
data["untaxed_amount"] = str(report.untaxed_amount)
|
||||
data["tax_amount"] = str(report.tax_amount)
|
||||
data["total"] = str(report.total_amount)
|
||||
data["untaxed_amount"] = str(record.untaxed_amount)
|
||||
data["tax_amount"] = str(record.tax_amount)
|
||||
data["total"] = str(record.total_amount)
|
||||
|
||||
if record.payments:
|
||||
data['payments'] = [{"statement": payment.statement.journal.name,
|
||||
"amount": str(payment.amount)} for payment in record.payments]
|
||||
|
||||
return data
|
||||
|
||||
def report_customer_order(records):
|
||||
|
Loading…
Reference in New Issue
Block a user