Bugfixes in "Händlerrabatt" + Report
parent
14dc3c2f7e
commit
01769a7a68
|
|
@ -103,3 +103,21 @@ class AccountInvoice(models.Model):
|
|||
self.ensure_one()
|
||||
self.sent = True
|
||||
return self.env.ref('account.account_invoices_without_payment').report_action(self)
|
||||
|
||||
@api.model
|
||||
def _formatLang(self, value, currency=True):
|
||||
lang = self.partner_id.lang
|
||||
lang_objs = self.env['res.lang'].search([('code', '=', lang)])
|
||||
if not lang_objs:
|
||||
lang_objs = self.env['res.lang'].search([], limit=1)
|
||||
lang_obj = lang_objs[0]
|
||||
|
||||
res = lang_obj.format('%.' + str(2) + 'f', value, grouping=True, monetary=True)
|
||||
currency_obj = self.currency_id
|
||||
|
||||
if currency_obj and currency_obj.symbol and currency:
|
||||
if currency_obj.position == 'after':
|
||||
res = '%s %s' % (res, currency_obj.symbol)
|
||||
elif currency_obj and currency_obj.position == 'before':
|
||||
res = '%s %s' % (currency_obj.symbol, res)
|
||||
return res
|
||||
|
|
|
|||
|
|
@ -353,6 +353,24 @@ class SaleOrder(models.Model):
|
|||
self.name = new_name
|
||||
return super(SaleOrder, self).action_confirm()
|
||||
|
||||
@api.model
|
||||
def _formatLang(self, value, currency=True):
|
||||
lang = self.partner_id.lang
|
||||
lang_objs = self.env['res.lang'].search([('code', '=', lang)])
|
||||
if not lang_objs:
|
||||
lang_objs = self.env['res.lang'].search([], limit=1)
|
||||
lang_obj = lang_objs[0]
|
||||
|
||||
res = lang_obj.format('%.' + str(2) + 'f', value, grouping=True, monetary=True)
|
||||
currency_obj = self.currency_id
|
||||
|
||||
if currency_obj and currency_obj.symbol and currency:
|
||||
if currency_obj.position == 'after':
|
||||
res = '%s %s' % (res, currency_obj.symbol)
|
||||
elif currency_obj and currency_obj.position == 'before':
|
||||
res = '%s %s' % (currency_obj.symbol, res)
|
||||
return res
|
||||
|
||||
|
||||
class SaleOrderLine(models.Model):
|
||||
_inherit = 'sale.order.line'
|
||||
|
|
@ -442,21 +460,23 @@ class SaleOrderLine(models.Model):
|
|||
@api.multi
|
||||
def calc_discount(self):
|
||||
discount = 0.0
|
||||
context_partner = dict(self.env.context, partner_id=self.order_id.partner_invoice_id.id, date=self.order_id.date_order)
|
||||
context_partner = dict(self.env.context, partner_id=self.order_id.partner_invoice_id.id,
|
||||
date=self.order_id.date_order)
|
||||
pricelist_context = dict(context_partner, uom=self.product_uom.id)
|
||||
|
||||
price, rule_id = self.order_id.pricelist_id.with_context(pricelist_context).get_product_price_rule(
|
||||
pricelist_id = self.order_id.partner_invoice_id.property_product_pricelist
|
||||
price, rule_id = pricelist_id.with_context(pricelist_context).get_product_price_rule(
|
||||
self.product_id, self.product_uom_qty or 1.0, self.order_id.partner_invoice_id)
|
||||
new_list_price, currency_id = self.with_context(context_partner)._get_real_price_currency(self.product_id,
|
||||
rule_id,
|
||||
self.product_uom_qty,
|
||||
self.product_uom,
|
||||
self.order_id.pricelist_id.id)
|
||||
pricelist_id.id)
|
||||
|
||||
if new_list_price != 0:
|
||||
if self.order_id.pricelist_id.currency_id.id != currency_id:
|
||||
if pricelist_id.currency_id.id != currency_id:
|
||||
# we need new_list_price in the same currency as price, which is in the SO's pricelist's currency
|
||||
new_list_price = self.env['res.currency'].browse(currency_id).with_context(context_partner).compute(
|
||||
new_list_price, self.order_id.pricelist_id.currency_id)
|
||||
new_list_price, pricelist_id.currency_id)
|
||||
discount = (new_list_price - price) / new_list_price * 100
|
||||
return discount
|
||||
|
|
|
|||
|
|
@ -88,9 +88,9 @@
|
|||
<thead class="table-header">
|
||||
<tr>
|
||||
<th class="text-center">Pos.</th>
|
||||
<th class="text-center">Anzahl</th>
|
||||
<th class="text-tight">Anzahl</th>
|
||||
<th class="text-right">Gewicht</th>
|
||||
<th class="text-right"></th>
|
||||
<th class="text-right"/>
|
||||
<th class="text-left">Artikel</th>
|
||||
<th class="text-right">EP</th>
|
||||
<th class="text-right" t-if="discount_is_set">Rabatt</th>
|
||||
|
|
@ -104,7 +104,7 @@
|
|||
<tr t-if="layout_category['name'] != 'Uncategorized'">
|
||||
<td colspan="6">
|
||||
<strong>
|
||||
<t t-esc="layout_category['name']"/> - <t t-esc="o.partner_id.ref"/><t t-if="layout_category['confirmation_nr']"> - <t t-esc="layout_category['confirmation_nr']"/></t>
|
||||
<t t-esc="layout_category['name']"/> - <t t-esc="o.partner_id.name"/><t t-if="layout_category['confirmation_nr']"> - <t t-esc="layout_category['confirmation_nr']"/></t>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="text-right" t-if="discount_is_set"/>
|
||||
|
|
@ -122,7 +122,7 @@
|
|||
<span t-esc="pos_nr"/>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span t-field="invoice_line.quantity"/>
|
||||
<span t-esc="o._formatLang(invoice_line.quantity, False).strip('0').strip(',')"/>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span t-field="invoice_line.weight"/>
|
||||
|
|
|
|||
|
|
@ -78,9 +78,9 @@
|
|||
<thead class="table-header">
|
||||
<tr>
|
||||
<th class="text-center">Pos.</th>
|
||||
<th class="text-center">Anzahl</th>
|
||||
<th class="text-right">Anzahl</th>
|
||||
<th class="text-right">Gewicht</th>
|
||||
<th class="text-right"></th>
|
||||
<th class="text-right"/>
|
||||
<th class="text-left">Artikel</th>
|
||||
<th class="text-right">EP</th>
|
||||
<th class="text-right" t-if="discount_is_set">Rabatt</th>
|
||||
|
|
@ -95,8 +95,8 @@
|
|||
<td class="text-center">
|
||||
<span t-esc="pos_nr"/>
|
||||
</td>
|
||||
<td class="text-left">
|
||||
<span t-field="order_line.product_uom_qty"/>
|
||||
<td class="text-right">
|
||||
<span t-esc="o._formatLang(order_line.product_uom_qty, False).strip('0').strip(',')"/>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<span t-field="order_line.weight"/> kg
|
||||
|
|
|
|||
Loading…
Reference in New Issue