Port hr_holidays_lunch_voucher and hr_holidays_lunch_voucher_natixis to v10

This commit is contained in:
Alexis de Lattre
2017-12-04 15:01:04 +01:00
parent 06a1d182e5
commit f9951890b5
25 changed files with 107 additions and 99 deletions

View File

@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
from . import company
from . import purchase_config_settings
from . import hr_holidays
from . import hr_employee
from . import lunch_voucher_attribution

View File

@@ -12,17 +12,21 @@
'description': '',
'author': 'Akretion',
'website': 'http://www.akretion.com',
'depends': ['hr_holidays_usability', 'purchase'],
'depends': [
'hr_holidays_usability',
'purchase',
'onchange_helper',
],
'data': [
'security/ir.model.access.csv',
'security/lunch_voucher_security.xml',
'product_data.xml',
'company_view.xml',
'purchase_config_settings_view.xml',
'wizard/lunch_voucher_purchase_view.xml',
'lunch_voucher_attribution_view.xml',
'hr_employee_view.xml',
'hr_holidays_view.xml',
'wizard/hr_holidays_post_view.xml',
'wizard/hr_holidays_to_payslip_view.xml',
],
'installable': True,
}

View File

@@ -3,8 +3,7 @@
# @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
import openerp.addons.decimal_precision as dp
from odoo import models, fields
class ResCompany(models.Model):
@@ -13,8 +12,8 @@ class ResCompany(models.Model):
lunch_voucher_product_id = fields.Many2one(
'product.product', string='Lunch Voucher Product',
ondelete='restrict')
lunch_voucher_employer_price = fields.Float(
'Lunch Voucher Employer Price', digits=dp.get_precision('Account'))
lunch_voucher_employer_price = fields.Monetary(
'Lunch Voucher Employer Price', currency_field='currency_id')
# Add constrain to check that lunch_voucher_employer_price is between
# 50% and 60% of the price of lunch_voucher_product_id for France

View File

@@ -3,7 +3,7 @@
# @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
from odoo import models, fields
class HrEmployee(models.Model):

View File

@@ -5,8 +5,7 @@
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<data>
<odoo>
<record id="view_employee_form_leave_inherit" model="ir.ui.view">
@@ -21,5 +20,4 @@
</record>
</data>
</openerp>
</odoo>

View File

@@ -3,7 +3,7 @@
# @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
@@ -18,7 +18,6 @@ class HrHolidays(models.Model):
store=True, string='Lunch Vouchers to Deduct')
@api.depends('employee_id', 'vacation_date_from', 'vacation_date_to')
@api.multi
def _compute_lunch_voucher_remove_qty(self):
hhpo = self.env['hr.holidays.public']
for hol in self:

View File

@@ -5,8 +5,7 @@
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<data>
<odoo>
<record id="edit_holiday_new" model="ir.ui.view">
@@ -29,11 +28,10 @@
<field name="inherit_id" ref="hr_holidays_usability.view_holiday"/>
<field name="arch" type="xml">
<field name="number_of_days" position="after">
<field name="lunch_voucher_remove_qty" string="Lunch Vouchers -=" sum="Total"/>
<field name="lunch_voucher_remove_qty" string="Lunch Vouchers -=" sum="1"/>
</field>
</field>
</record>
</data>
</openerp>
</odoo>

View File

@@ -3,7 +3,7 @@
# @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
class LunchVoucherAttribution(models.Model):
@@ -35,7 +35,6 @@ class LunchVoucherAttribution(models.Model):
'hr.holidays', 'lunch_voucher_id', readonly=True)
@api.depends('month_work_days', 'holiday_ids.lunch_voucher_remove_qty')
@api.multi
def _compute_qty(self):
for rec in self:
no_lunch_days = 0

View File

@@ -5,8 +5,7 @@
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<data>
<odoo>
<record id="lunch_voucher_attribution_form" model="ir.ui.view">
@@ -38,7 +37,7 @@
<field name="date"/>
<field name="employee_id"/>
<field name="month_work_days"/>
<field name="no_lunch_days" sum="Total"/>
<field name="no_lunch_days" sum="1"/>
<field name="qty" sum="Total"/>
<field name="purchase_id"/>
<field name="company_id" groups="base.group_multi_company"/>
@@ -93,5 +92,4 @@
view_mode="form"
target="new" />
</data>
</openerp>
</odoo>

View File

@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<odoo noupdate="1">
<record id="lunch_voucher_product" model="product.product">
@@ -23,5 +22,4 @@
</record>
</data>
</openerp>
</odoo>

View File

@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
# © 2017 Akretion - Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import fields, models
class PurchaseConfigSettings(models.TransientModel):
_inherit = 'purchase.config.settings'
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')

View File

@@ -5,16 +5,15 @@
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<data>
<odoo>
<record id="view_company_form" model="ir.ui.view">
<field name="name">lunch_voucher.company.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<record id="view_purchase_configuration" model="ir.ui.view">
<field name="name">lunch_voucher.purchase.config.settings.form</field>
<field name="model">purchase.config.settings</field>
<field name="inherit_id" ref="purchase.view_purchase_configuration"/>
<field name="arch" type="xml">
<group name="account_grp" position="after">
<xpath expr="//field[@name='module_stock_dropshipping']/.." position="after">
<group name="lunch_voucher" string="Lunch Vouchers">
<field name="lunch_voucher_product_id"/>
<!-- <field name="lunch_voucher_po_type"/> -->
@@ -25,5 +24,4 @@
</record>
</data>
</openerp>
</odoo>

View File

@@ -1,3 +1,3 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
access_lunch_voucher_attribution_full,Full access on lunch_voucher_attribution,model_lunch_voucher_attribution,base.group_hr_manager,1,1,1,1
access_lunch_voucher_attribution_full,Full access on lunch_voucher_attribution,model_lunch_voucher_attribution,hr.group_hr_manager,1,1,1,1
access_lunch_voucher_attribution_read,Read access on lunch_voucher_attribution,model_lunch_voucher_attribution,base.group_user,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 access_lunch_voucher_attribution_full Full access on lunch_voucher_attribution model_lunch_voucher_attribution base.group_hr_manager hr.group_hr_manager 1 1 1 1
3 access_lunch_voucher_attribution_read Read access on lunch_voucher_attribution model_lunch_voucher_attribution base.group_user 1 0 0 0

View File

@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<openerp>
<data noupdate="1">
<odoo noupdate="1">
<record id="lunch_voucher_attribution_employee" model="ir.rule">
@@ -24,5 +23,4 @@
</record>
</data>
</openerp>
</odoo>

View File

@@ -1,4 +1,4 @@
# -*- encoding: utf-8 -*-
from . import hr_holidays_post
from . import hr_holidays_to_payslip
from . import lunch_voucher_purchase

View File

@@ -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()

View File

@@ -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>

View File

@@ -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})

View File

@@ -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>

View File

@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
from . import company
from . import purchase_config_settings
from . import wizard

View File

@@ -14,7 +14,7 @@
'website': 'http://www.akretion.com',
'depends': ['hr_holidays_lunch_voucher'],
'data': [
'company_view.xml',
'purchase_config_settings_view.xml',
],
'installable': True,
}

View File

@@ -3,7 +3,7 @@
# @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
from odoo import models, fields
class ResCompany(models.Model):

View File

@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# © 2017 Akretion (http://www.akretion.com)
# @author Alexis de Lattre <alexis.delattre@akretion.com>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields
class PurchaseConfigSettings(models.TransientModel):
_inherit = 'purchase.config.settings'
lunch_voucher_natixis_customer_code = fields.Char(
related='company_id.lunch_voucher_natixis_customer_code')
lunch_voucher_natixis_delivery_code = fields.Char(
related='company_id.lunch_voucher_natixis_delivery_code')

View File

@@ -5,14 +5,13 @@
License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
-->
<openerp>
<data>
<odoo>
<record id="view_company_form" model="ir.ui.view">
<field name="name">natixis.lunch_voucher.company.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="hr_holidays_lunch_voucher.view_company_form"/>
<record id="view_purchase_configuration" model="ir.ui.view">
<field name="name">natixis.lunch_voucher.purchase.config.settings.form</field>
<field name="model">purchase.config.settings</field>
<field name="inherit_id" ref="hr_holidays_lunch_voucher.view_purchase_configuration"/>
<field name="arch" type="xml">
<group name="lunch_voucher" position="inside">
<field name="lunch_voucher_natixis_customer_code"/>
@@ -22,5 +21,4 @@
</record>
</data>
</openerp>
</odoo>

View File

@@ -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, fields, api, _
from openerp.exceptions import Warning as UserError
from openerp.tools import float_is_zero
from odoo import models, fields, _
from odoo.exceptions import UserError
from odoo.tools import float_is_zero
class LunchVoucherPurchase(models.TransientModel):
_inherit = 'lunch.voucher.purchase'
@api.multi
def run(self):
self.ensure_one()
action = super(LunchVoucherPurchase, self).run()