Port hr_holidays_lunch_voucher and hr_holidays_lunch_voucher_natixis to v10
This commit is contained in:
@@ -3,15 +3,14 @@
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import models, api, _
|
||||
from openerp.exceptions import Warning as UserError
|
||||
from odoo import models, _
|
||||
from odoo.exceptions import UserError
|
||||
|
||||
|
||||
class LunchVoucherPurchase(models.TransientModel):
|
||||
_name = 'lunch.voucher.purchase'
|
||||
_description = 'Purchase Lunch Vouchers Wizard'
|
||||
|
||||
@api.multi
|
||||
def run(self):
|
||||
self.ensure_one()
|
||||
company = self.env.user.company_id
|
||||
@@ -45,24 +44,19 @@ class LunchVoucherPurchase(models.TransientModel):
|
||||
% lvoucher.employee_id.name)
|
||||
total_qty += lvoucher.qty
|
||||
|
||||
supplier = company.lunch_voucher_product_id.seller_id
|
||||
supplier = company.lunch_voucher_product_id.seller_ids[0]
|
||||
pick_type_id = poo.default_get(['picking_type_id'])['picking_type_id']
|
||||
onchange_ptype_vals = poo.browse(False).onchange_picking_type_id(
|
||||
pick_type_id)
|
||||
vals = onchange_ptype_vals['value']
|
||||
onchange_vals = poo.browse(False).onchange_partner_id(supplier.id)
|
||||
vals.update(onchange_vals['value'])
|
||||
vals['partner_id'] = supplier.id
|
||||
vals = {'picking_type_id': pick_type_id, 'partner_id': supplier.id}
|
||||
vals = poo.play_onchanges(vals, ['picking_type_id'])
|
||||
vals = poo.play_onchanges(vals, ['partner_id'])
|
||||
|
||||
product = company.lunch_voucher_product_id
|
||||
onchange_product_vals = polo.browse(False).onchange_product_id(
|
||||
vals.get('pricelist_id'), product.id, total_qty, False,
|
||||
supplier.id, fiscal_position_id=vals.get('fiscal_position_id'))
|
||||
lvals = onchange_product_vals['value']
|
||||
lvals['product_id'] = product.id
|
||||
lvals['product_qty'] = total_qty
|
||||
if lvals['taxes_id']:
|
||||
lvals['taxes_id'] = [(6, 0, lvals['taxes_id'])]
|
||||
lvals = {
|
||||
'product_id': company.lunch_voucher_product_id.id,
|
||||
'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)
|
||||
lvouchers.write({'purchase_id': po.id})
|
||||
|
||||
Reference in New Issue
Block a user