Skip to Content
Menu
This question has been flagged
1 Reply
3154 Views

Hi everybody,

I would like to add in the report_detailsofsales.xml file price_subtotal field but i get error.

                    <tbody>
<tr t-foreach="pos_sales_details(data['form'])" t-as="line_ids" >
<td>
<span t-esc="formatLang(line_ids['date_order'], date_time=True)"/>
</td>
<td>
<span t-esc="line_ids['pos_name']"/>
</td>
<td>
[<t t-if="line_ids['code']">
<span t-esc="line_ids['code']"/>
</t>]
<span t-esc="line_ids['name']"/>
</td>
<td class="text-right">
<span t-esc="formatLang(line_ids['price_unit'], dp='Sale Price', currency_obj=res_company.currency_id)"/>
</td>
<td class="text-center">
<span t-esc="formatLang(line_ids['qty'])"/>
<span t-esc="line_ids['uom']"/>
</td>
<td class="text-center">
<span t-esc="formatLang(line_ids['discount'], dp='Sale Price')"/>
</td>
<td class="text-center">
<span t-esc="formatLang(line_ids['price_subtotal'], dp='Sale Price', currency_obj=res_company.currency_id)"/>
</td>

<td class="text-center">
<t t-if="line_ids['invoice_id']">
<span t-esc="getinvoice(line_ids['invoice_id'])"/>
</t>
</td>
</tr>
</tbody>


Can you help me. Thanks.

Avatar
Discard
Best Answer

If you want to add any fields into your report , you first define or call that variable into your py file, i will give you an example,

class report_manufacturing_order(report_sxw.rml_parse):
def __init__(self, cr, uid, name, context):
super(report_manufacturing_order, self).__init__(cr, uid, name, context=context)
self.localcontext.update( {
'time': time,
'product_record': self._product_record,
})

def _product_record(self, production_ids):

product_obj = self.pool.get('mrp.production')
res = []
for production_data in product_obj.browse(self.cr, self.uid, production_ids):
# product_ids = self.pool.get('product.product').search(self.cr, self.uid, [('product_id','=',production_data.id)])
vals = {
# 'employee_id' : employee_data.employee_id,
'order_no' : production_data.name,
'product_name' : production_data.product_id.name,
'customer' : production_data.partner_id.name,
'quantity' : production_data.product_qty,
'start' : production_data.date_planned,
'end' : production_data.end_date_planned,
'cost' : production_data.product_id.cost_price
}
res.append(vals)
return res
class report_manufacturing_order_AbstractModel(osv.AbstractModel):
_name = 'report.ncr_report.report_manufacturing_order_template'
_inherit = 'report.abstract_report'
_template = 'ncr_report.report_manufacturing_order_template'
_wrapped_report_class = report_manufacturing_order

***********************

then you need to return that values and , call from xml file,

another 

 

Avatar
Discard
Author

Hi prasanth.ks, report_detailsofsales is based on a wizard. But in the py file of this wizard i have just see tree fields. but when you was seeing the xml file we have more than tree field. I don't understand anythink. Thanks

Author

Sorry prasanth.ks, you right. i am working on bad py file. The right py file is pos_details.py. thanks

Related Posts Replies Views Activity
0
Aug 24
106
2
Aug 24
218
1
Aug 24
544
3
May 24
7263
1
Sep 23
1337