diff --git a/addons/sale_category/__init__.py b/addons/sale_category/__init__.py new file mode 100644 index 00000000000..4cb5de9f910 --- /dev/null +++ b/addons/sale_category/__init__.py @@ -0,0 +1 @@ +import report diff --git a/addons/sale_category/__terp__.py b/addons/sale_category/__terp__.py new file mode 100644 index 00000000000..3bed7a6185e --- /dev/null +++ b/addons/sale_category/__terp__.py @@ -0,0 +1,11 @@ +{ + "name" : "Sale Order Line With Categories", + "author" : "Tiny", + "version" : "1.0", + "category" : "Generic Modules/Sales & Purchases", + "depends" : ["sale"], + "demo_xml" : [], + "update_xml" : ["sale_category_report.xml"], + "active": True, + "installable": True +} diff --git a/addons/sale_category/report/__init__.py b/addons/sale_category/report/__init__.py new file mode 100644 index 00000000000..d4a1c2654b4 --- /dev/null +++ b/addons/sale_category/report/__init__.py @@ -0,0 +1 @@ +import sale_category_report diff --git a/addons/sale_category/report/sale_category_report.py b/addons/sale_category/report/sale_category_report.py new file mode 100644 index 00000000000..dadc81f4e87 --- /dev/null +++ b/addons/sale_category/report/sale_category_report.py @@ -0,0 +1,37 @@ +import pooler +import time +from report import report_sxw + +class sale_category_report(report_sxw.rml_parse): + # o must be an instance of sale_order. Returns a list of 2-tuple + # (category name, [list of sale_order_line of this category]) + def order_lines_by_categ(self, o): + # result is a dictionnary where keys are category + # names and values are lists of sale_category_sale_order_line. + + self.pool = pooler.get_pool(self.cr.dbname) + ids = self.pool.get('product.category').search(self.cr, self.uid, [('parent_id','=',False)]) + cats = map(lambda x: (x, (x.sequence,)), self.pool.get('product.category').browse(self.cr, self.uid, ids)) + pos = 0 + result = {} + while pos + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [[ repeatIn(objects,'o') ]] [[ setLang(o.partner_id.lang) ]] + + + + Shipping address : + [[ o.partner_id.title or '' ]] [[ o.partner_id.name ]] + [[ o.partner_shipping_id.title or '' ]] [[ o.partner_shipping_id.name ]] + [[ o.partner_shipping_id.street ]] + [[ o.partner_shipping_id.street2 or '' ]] + [[ o.partner_shipping_id.zip or '' ]] [[ o.partner_shipping_id.city or '' ]] + [[ o.partner_shipping_id.state_id and o.partner_shipping_id.state_id.name or '' ]] + [[ o.partner_shipping_id.country_id and o.partner_shipping_id.country_id.name or '' ]] + + + + Invoice address : + [[ o.partner_invoice_id.street ]][[ o.partner_invoice_id.street2 and ', %s' % o.partner_invoice_id.street2 or '' ]] + [[ o.partner_invoice_id.zip or '' ]] [[ o.partner_invoice_id.city or '' ]] [[ ', %s' % (o.partner_invoice_id.country_id and o.partner_invoice_id.country_id.name or '') ]] + + + + + + + + [[ o.partner_id.title or '' ]] [[ o.partner_id.name ]] + [[ o.partner_order_id.title or '' ]] [[ o.partner_order_id.name ]] + [[ o.partner_order_id.street ]] + [[ o.partner_order_id.street2 or '' ]] + [[ o.partner_order_id.zip or '' ]] [[ o.partner_order_id.city or '' ]] + [[ o.partner_order_id.state_id and o.partner_order_id.state_id.name or '' ]] + [[ o.partner_order_id.country_id and o.partner_order_id.country_id.name or '' ]] + + + + Tél. : [[ o.partner_order_id.phone or '' ]] + Fax : [[ o.partner_order_id.fax or '' ]] + TVA : [[ o.partner_id.vat or '' ]] + + + + + + + [[ o.state=='draft' and 'Quotation ' or 'Order ' ]] N° : [[ o.name ]] + + + + Your order reference : [[ o.client_order_ref or '' ]] + Date ordered : [[ time.strftime('%d/%m/%Y', time.strptime(o.date_order, '%Y-%m-%d')) ]] + Our salesman : [[ o.user_id.name ]] + [[o.topnote or '']] + + + + Product Description + + + Applicable Taxes + + + Date Promised + + + Qty + + + Disc. + + + Unit Price + + + Net Price + + + +
+ [[repeatIn(order_lines_by_categ(o), 'cat')]] + [[cat[0][1] ]] +
+ [[ repeatIn(cat[1],'line') ]] + + + + [[ line.name ]] + + + [[ ', '.join(map(lambda x: x.name, line.tax_id))]] + + + [[ time.strftime('%d/%m/%Y', time.strptime( line.date_planned, '%Y-%m-%d')) ]] + + + [[ line.product_uom_qty ]] [[ line.product_uom.name ]] + + + [[ (line.discount and str(line.discount)+'%')or '' ]] + + + [[ '%.2f' % line.price_unit ]] + + + [[ '%.2f' % line.price_subtotal ]] + + + + + + +
+ + + + [[ repeatIn((line.notes and [line.notes]) or [], 'l') ]] + + + [[ l ]] [[ setTag('para','xpre') ]] + + + + + + + + +
+ + + + + + + + + Net Total : + + + [[ '%.2f' % o.amount_untaxed ]] [[ o.pricelist_id.currency_id.name ]] + + + + + + + + + + Taxes : + + + [[ '%.2f' % o.amount_tax ]] [[ o.pricelist_id.currency_id.name ]] + + + + + + + + + + TOTAL : + + + [[ '%.2f' % o.amount_total ]] [[ o.pricelist_id.currency_id.name ]] + + + + + + + + + + + + + [[ o.note or '' ]] [[ setTag('para','xpre') ]] + + + + + [[ 'xpre' and o.partner_id.property_payment_term and o.partner_id.property_payment_term[1] ]] [[ setTag('para','xpre') ]] + + + + + + +
+
+ diff --git a/addons/sale_category/sale_category_report.xml b/addons/sale_category/sale_category_report.xml new file mode 100644 index 00000000000..1b9f4021f3d --- /dev/null +++ b/addons/sale_category/sale_category_report.xml @@ -0,0 +1,11 @@ + + + + + +