add report service order

This commit is contained in:
Wilson Gomez 2023-02-02 14:38:47 -05:00
parent 45f0f96b50
commit dc7cb85681
3 changed files with 40 additions and 12 deletions

Binary file not shown.

View File

@ -4,7 +4,7 @@ from datetime import date
from decimal import Decimal
from trytond.model import Workflow, ModelView, ModelSQL, fields
from trytond.pyson import Eval, If, In, Get, Bool, Or, Not, Equal
from trytond.pyson import Eval, If, In, Get, Bool, Or, Not, Equal, Id
from trytond.transaction import Transaction
from trytond.pool import Pool, PoolMeta
from trytond.wizard import Wizard, StateReport, StateTransition, StateView, Button
@ -706,6 +706,7 @@ class OrderLine(Workflow, ModelSQL, ModelView):
order_state = fields.Function(
fields.Selection('get_order_states', "Order State"),
'on_change_with_order_state')
amount = fields.Function(fields.Numeric('Amount'), 'get_amount')
@classmethod
def __setup__(cls):
@ -716,6 +717,10 @@ class OrderLine(Workflow, ModelSQL, ModelView):
def default_quantity():
return 1
def get_amount(self, name=None):
if self.quantity and self.unit_price:
return Decimal(self.quantity) * self.unit_price
@classmethod
def get_order_states(cls):
pool = Pool()
@ -769,13 +774,21 @@ class OrderLine(Workflow, ModelSQL, ModelView):
class ServiceOrderReport(Report):
__name__ = 'laboratory.order'
__name__ = 'laboratory.order.report'
@classmethod
def get_context(cls, records, header, data):
Company = Pool().get('company.company')
context = super(ServiceOrderReport, cls).get_context(records, header,
data)
report_id = data['action_id']
order_receip_id = Id('laboratory', 'service_order_receip').pyson()
if report_id == order_receip_id:
type_doc = 'order_receip'
else:
type_doc = 'order'
context['type_doc'] = type_doc
context['company'] = Company(Transaction().context.get('company'))
return context

View File

@ -123,18 +123,33 @@ this repository contains the full copyright notices and license terms. -->
<field name="type">form</field>
<field name="name">order_payment_form</field>
</record>
<!-- <record model="ir.action.wizard" id="wizard_order_indicators">
<field name="name">Service Order Indicators</field>
<field name="wiz_name">laboratory.order_indicators</field>
<record model="ir.action.report" id="service_order">
<field name="name">Service Order Remision</field>
<field name="model">laboratory.order</field>
<field name="report_name">laboratory.order.report</field>
<field name="report">laboratory/service_order.fodt</field>
<field name="template_extension">odt</field>
<field name="translatable">False</field>
</record>
<record model="ir.action.report" id="report_order_indicators">
<field name="name">Service Order Indicators</field>
<field name="model"></field>
<field name="report_name">laboratory.order_indicators_report</field>
<field name="report">laboratory/order_indicator.ods</field>
<record model="ir.action.report" id="service_order_receip">
<field name="name">Service Order Receip</field>
<field name="model">laboratory.order</field>
<field name="report_name">laboratory.order.report</field>
<field name="report">laboratory/service_order.fodt</field>
<field name="template_extension">odt</field>
<field name="translatable">False</field>
</record>
<menuitem parent="laboratory.menu_reports" action="wizard_order_indicators"
<record model="ir.action.keyword" id="act_report_service_order_keyword">
<field name="keyword">form_print</field>
<field name="model">laboratory.order,-1</field>
<field name="action" ref="service_order"/>
</record>
<record model="ir.action.keyword" id="act_service_order_receip_keyword">
<field name="keyword">form_print</field>
<field name="model">laboratory.order,-1</field>
<field name="action" ref="service_order_receip"/>
</record>
<!-- <menuitem parent="laboratory.menu_reports" action="wizard_order_indicators"
id="menu_order_indicators" icon="tryton-print"/> -->