From 01769a7a68287270707bdb69d2f7de5e70df673e Mon Sep 17 00:00:00 2001 From: Ahmed Aly Date: Thu, 5 Apr 2018 10:10:11 +0200 Subject: [PATCH] =?UTF-8?q?Bugfixes=20in=20"H=C3=A4ndlerrabatt"=20+=20Repo?= =?UTF-8?q?rt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ext/custom-addons/dp_custom/models/account.py | 18 +++++++++++ ext/custom-addons/dp_custom/models/sale.py | 30 +++++++++++++++---- .../dp_reports_account/reports/invoice.xml | 8 ++--- .../dp_reports_sale/reports/sale.xml | 8 ++--- 4 files changed, 51 insertions(+), 13 deletions(-) diff --git a/ext/custom-addons/dp_custom/models/account.py b/ext/custom-addons/dp_custom/models/account.py index 25634ffe..51b43852 100644 --- a/ext/custom-addons/dp_custom/models/account.py +++ b/ext/custom-addons/dp_custom/models/account.py @@ -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 diff --git a/ext/custom-addons/dp_custom/models/sale.py b/ext/custom-addons/dp_custom/models/sale.py index baa7c48c..cfe28dfe 100644 --- a/ext/custom-addons/dp_custom/models/sale.py +++ b/ext/custom-addons/dp_custom/models/sale.py @@ -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 diff --git a/ext/custom-addons/dp_reports_account/reports/invoice.xml b/ext/custom-addons/dp_reports_account/reports/invoice.xml index d87ed139..1a24c924 100644 --- a/ext/custom-addons/dp_reports_account/reports/invoice.xml +++ b/ext/custom-addons/dp_reports_account/reports/invoice.xml @@ -88,9 +88,9 @@ Pos. - Anzahl + Anzahl Gewicht - + Artikel EP Rabatt @@ -104,7 +104,7 @@ - - - + - - @@ -122,7 +122,7 @@ - + diff --git a/ext/custom-addons/dp_reports_sale/reports/sale.xml b/ext/custom-addons/dp_reports_sale/reports/sale.xml index d8f159e8..c79afdc3 100644 --- a/ext/custom-addons/dp_reports_sale/reports/sale.xml +++ b/ext/custom-addons/dp_reports_sale/reports/sale.xml @@ -78,9 +78,9 @@ Pos. - Anzahl + Anzahl Gewicht - + Artikel EP Rabatt @@ -95,8 +95,8 @@ - - + + kg