Browse Source

Delete line pack in PDF sale and account line

12.0
Juliana 5 years ago
parent
commit
b16bb718d6
  1. 1
      __manifest__.py
  2. 19
      models/sale_order.py
  3. 66
      report/sale_report.xml

1
__manifest__.py

@ -13,5 +13,6 @@
], ],
"data": [ "data": [
'security/ir.model.access.csv', 'security/ir.model.access.csv',
'report/sale_report.xml'
] ]
} }

19
models/sale_order.py

@ -12,3 +12,22 @@ class SaleOrder(models.Model):
self.website_order_line = self.order_line.filtered( self.website_order_line = self.order_line.filtered(
lambda t: not t.pack_parent_line_id.exists(), lambda t: not t.pack_parent_line_id.exists(),
) )
class SaleOrderLine(models.Model):
_inherit = "sale.order.line"
@api.multi
def invoice_line_create(self, invoice_id, qty):
invoice_lines = self.env['account.invoice.line']
for line in self:
# Check if line has a pack_parent_line_id
if self.pack_parent_line_id.exists():
# Get the ref of parent pack
sale_id_ref = self.env['sale.order.line'].search([('id', '=', self.pack_parent_line_id.id)])
# Check if product is Pack detailed and option Totalized
if sale_id_ref.product_id.product_tmpl_id.pack_type == 'detailed' and sale_id_ref.product_id.product_tmpl_id.pack_component_price == 'totalized':
return invoice_lines
invoice_lines = super(SaleOrderLine, self).invoice_line_create(
invoice_id, qty)
return invoice_lines

66
report/sale_report.xml

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<template id="vracoop_report_saleorder_document" inherit_id="sale.report_saleorder_document">
<xpath expr="//tbody[@class='sale_tbody']" position="replace">
<tbody class="sale_tbody">
<t t-set="current_subtotal" t-value="0"/>
<t t-foreach="doc.order_line" t-as="line">
<t t-if="not line.pack_parent_line_id">
<t t-set="current_subtotal" t-value="current_subtotal + line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<t t-set="current_subtotal" t-value="current_subtotal + line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
<tr t-att-class="'bg-200 font-weight-bold o_line_section' if line.display_type == 'line_section' else 'font-italic o_line_note' if line.display_type == 'line_note' else ''">
<t t-if="not line.display_type">
<td><span t-field="line.name"/></td>
<td class="text-right">
<span t-field="line.product_uom_qty"/>
<span t-field="line.product_uom" groups="uom.group_uom"/>
</td>
<td class="text-right">
<span t-field="line.price_unit"/>
</td>
<td t-if="display_discount" class="text-right" groups="sale.group_discount_per_so_line">
<span t-field="line.discount"/>
</td>
<td class="text-right">
<span t-esc="', '.join(map(lambda x: (x.description or x.name), line.tax_id))"/>
</td>
<td class="text-right o_price_total">
<span t-field="line.price_subtotal" groups="account.group_show_line_subtotals_tax_excluded"/>
<span t-field="line.price_total" groups="account.group_show_line_subtotals_tax_included"/>
</td>
</t>
<t t-if="line.display_type == 'line_section'">
<td t-att-colspan="colspan">
<span t-field="line.name"/>
</td>
<t t-set="current_section" t-value="line"/>
<t t-set="current_subtotal" t-value="0"/>
</t>
<t t-if="line.display_type == 'line_note'">
<td t-att-colspan="colspan">
<span t-field="line.name"/>
</td>
</t>
</tr>
<t t-if="current_section and (line_last or doc.order_line[line_index+1].display_type == 'line_section')">
<tr class="is-subtotal text-right">
<td t-att-colspan="colspan">
<strong class="mr16">Sous-total</strong>
<span
t-esc="current_subtotal"
t-options='{"widget": "monetary", "display_currency": doc.pricelist_id.currency_id}'
/>
</td>
</tr>
</t>
</t>
</t>
</tbody>
</xpath>
</template>
</odoo>
Loading…
Cancel
Save