Port hr_holidays_lunch_voucher and hr_holidays_lunch_voucher_natixis to v10
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# -*- encoding: utf-8 -*-
|
||||
|
||||
from . import hr_holidays_post
|
||||
from . import hr_holidays_to_payslip
|
||||
from . import lunch_voucher_purchase
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
# @author Alexis de Lattre <alexis.delattre@akretion.com>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
from openerp import models, fields, api
|
||||
from odoo import models, fields, api
|
||||
from dateutil.relativedelta import relativedelta
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HrHolidaysPost(models.TransientModel):
|
||||
_inherit = 'hr.holidays.post'
|
||||
class HrHolidaysToPayslip(models.TransientModel):
|
||||
_inherit = 'hr.holidays.to.payslip'
|
||||
|
||||
lunch_voucher_po = fields.Boolean(
|
||||
string='Generate Lunch Voucher Purchase Order')
|
||||
@@ -19,7 +19,7 @@ class HrHolidaysPost(models.TransientModel):
|
||||
|
||||
@api.model
|
||||
def default_get(self, fields_list):
|
||||
res = super(HrHolidaysPost, self).default_get(fields_list)
|
||||
res = super(HrHolidaysToPayslip, self).default_get(fields_list)
|
||||
hhpo = self.env['hr.holidays.public']
|
||||
company = self.env.user.company_id
|
||||
if company.lunch_voucher_product_id:
|
||||
@@ -47,7 +47,6 @@ class HrHolidaysPost(models.TransientModel):
|
||||
res['work_days'] = work_days
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def run(self):
|
||||
self.ensure_one()
|
||||
lvao = self.env['lunch.voucher.attribution']
|
||||
@@ -59,7 +58,7 @@ class HrHolidaysPost(models.TransientModel):
|
||||
lv_dict = {}
|
||||
for employee in employees:
|
||||
lv_dict[employee.id] = []
|
||||
for hol in self.holidays_to_post_ids:
|
||||
for hol in self.holidays_to_payslip_ids:
|
||||
if not hol.lunch_voucher_id and hol.employee_id.id in lv_dict:
|
||||
lv_dict[hol.employee_id.id].append(hol.id)
|
||||
for employee_id, hol_ids in lv_dict.iteritems():
|
||||
@@ -71,4 +70,4 @@ class HrHolidaysPost(models.TransientModel):
|
||||
if hol_ids:
|
||||
vals['holiday_ids'] = [(6, 0, hol_ids)]
|
||||
lvao.create(vals)
|
||||
return super(HrHolidaysPost, self).run()
|
||||
return super(HrHolidaysToPayslip, self).run()
|
||||
@@ -5,16 +5,15 @@
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
<odoo>
|
||||
|
||||
|
||||
<record id="hr_holidays_post_form" model="ir.ui.view">
|
||||
<field name="name">hr_holidays_post_form</field>
|
||||
<field name="model">hr.holidays.post</field>
|
||||
<field name="inherit_id" ref="hr_holidays_usability.hr_holidays_post_form"/>
|
||||
<record id="hr_holidays_to_payslip_form" model="ir.ui.view">
|
||||
<field name="name">hr.holidays.to.payslip.form</field>
|
||||
<field name="model">hr.holidays.to.payslip</field>
|
||||
<field name="inherit_id" ref="hr_holidays_usability.hr_holidays_to_payslip_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<field name="holidays_to_post_ids" position="before">
|
||||
<field name="holidays_to_payslip_ids" position="before">
|
||||
<field name="lunch_voucher_po" states="done"/>
|
||||
<field name="work_days"
|
||||
attrs="{'invisible': ['|', ('state', '!=', 'done'), ('lunch_voucher_po', '=', False)]}"/>
|
||||
@@ -23,5 +22,4 @@
|
||||
</record>
|
||||
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
</odoo>
|
||||
@@ -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})
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
-->
|
||||
|
||||
<openerp>
|
||||
<data>
|
||||
<odoo>
|
||||
|
||||
|
||||
<record id="lunch_voucher_purchase_form" model="ir.ui.view">
|
||||
<field name="name">lunch_voucher_purchase_form</field>
|
||||
@@ -18,7 +18,7 @@
|
||||
</group>
|
||||
<footer>
|
||||
<button name="run" type="object" string="Create"
|
||||
class="oe_highlight"/>
|
||||
class="btn-primary"/>
|
||||
<button special="cancel" string="Cancel" class="oe_link"/>
|
||||
</footer>
|
||||
</form>
|
||||
@@ -32,5 +32,5 @@
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
|
||||
</odoo>
|
||||
|
||||
Reference in New Issue
Block a user