From 559c301f2c00c7d9e399327d5f37512e43d75f0a Mon Sep 17 00:00:00 2001 From: Alexis de Lattre Date: Tue, 19 Dec 2017 12:23:15 +0100 Subject: [PATCH] FIX hr_holidays_lunch_voucher and hr_holidays_lunch_voucher_natixis --- hr_holidays_lunch_voucher/purchase_config_settings.py | 3 ++- .../wizard/lunch_voucher_purchase.py | 5 ++--- .../wizard/lunch_voucher_purchase.py | 9 +++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/hr_holidays_lunch_voucher/purchase_config_settings.py b/hr_holidays_lunch_voucher/purchase_config_settings.py index e33381b..b90c155 100644 --- a/hr_holidays_lunch_voucher/purchase_config_settings.py +++ b/hr_holidays_lunch_voucher/purchase_config_settings.py @@ -11,4 +11,5 @@ class PurchaseConfigSettings(models.TransientModel): lunch_voucher_product_id = fields.Many2one( related='company_id.lunch_voucher_product_id') lunch_voucher_employer_price = fields.Monetary( - related='company_id.lunch_voucher_employer_price') + related='company_id.lunch_voucher_employer_price', + currency_field='company_currency_id') diff --git a/hr_holidays_lunch_voucher/wizard/lunch_voucher_purchase.py b/hr_holidays_lunch_voucher/wizard/lunch_voucher_purchase.py index 503f690..fc818ae 100644 --- a/hr_holidays_lunch_voucher/wizard/lunch_voucher_purchase.py +++ b/hr_holidays_lunch_voucher/wizard/lunch_voucher_purchase.py @@ -18,7 +18,7 @@ class LunchVoucherPurchase(models.TransientModel): raise UserError(_( "Lunch Voucher Product not configured on company %s") % company.name) - if not company.lunch_voucher_product_id.seller_id: + if not company.lunch_voucher_product_id.seller_ids: raise UserError(_( "Missing supplier on Product '%s'.") % company.lunch_voucher_product_id.name) @@ -44,7 +44,7 @@ class LunchVoucherPurchase(models.TransientModel): % lvoucher.employee_id.name) total_qty += lvoucher.qty - supplier = company.lunch_voucher_product_id.seller_ids[0] + supplier = company.lunch_voucher_product_id.seller_ids[0].name pick_type_id = poo.default_get(['picking_type_id'])['picking_type_id'] vals = {'picking_type_id': pick_type_id, 'partner_id': supplier.id} vals = poo.play_onchanges(vals, ['picking_type_id']) @@ -55,7 +55,6 @@ class LunchVoucherPurchase(models.TransientModel): 'order_id': vals, 'product_qty': total_qty} lvals = polo.play_onchanges(lvals, ['product_id']) # TODO check lvals['taxes_id'] uses (6, 0, ...) - print "lvals=", lvals lvals.pop('order_id') vals['order_line'] = [(0, 0, lvals)] po = poo.create(vals) diff --git a/hr_holidays_lunch_voucher_natixis/wizard/lunch_voucher_purchase.py b/hr_holidays_lunch_voucher_natixis/wizard/lunch_voucher_purchase.py index 52b17eb..ce1ff1f 100644 --- a/hr_holidays_lunch_voucher_natixis/wizard/lunch_voucher_purchase.py +++ b/hr_holidays_lunch_voucher_natixis/wizard/lunch_voucher_purchase.py @@ -46,14 +46,16 @@ class LunchVoucherPurchase(models.TransientModel): "Lunch Voucher Employer Price not set on company '%s'.") % company.name) if float_is_zero( - company.lunch_voucher_product_id.standard_price, + company.lunch_voucher_product_id.seller_ids[0].price, precision_digits=2): raise UserError(_( - "Lunch Voucher Standard Price is not set on product '%s'.") + "Lunch Voucher Price on supplier info is not set " + "on product '%s'.") % company.lunch_voucher_product_id.display_name) lvouchers = lvao.browse(self._context['active_ids']) of = u'' tmp = {} + price = company.lunch_voucher_product_id.seller_ids[0].price for lvoucher in lvouchers: if lvoucher.qty > 0: if lvoucher.qty not in tmp: @@ -70,8 +72,7 @@ class LunchVoucherPurchase(models.TransientModel): unicode(pack_qty).zfill(3), unicode(vouchers_per_pack).zfill(2), unicode(pack_qty * vouchers_per_pack).zfill(5), - '{:05.2f}'.format( - company.lunch_voucher_product_id.standard_price), + '{:05.2f}'.format(price), '{:05.2f}'.format(company.lunch_voucher_employer_price), ' ' * 64) of += line