diff options
| author | Joren Van Onder <jov@odoo.com> | 2015-07-14 09:24:45 +0200 |
|---|---|---|
| committer | Antony Lesuisse <al@openerp.com> | 2015-08-03 21:51:59 +0200 |
| commit | 7b32ca8452d395578bca43c3b7efd1d3f09011cb (patch) | |
| tree | cdfd460a7781db5e35007f3a911efa0577365dd1 | |
| parent | 2a528aba299bc044715c36bf6106fca4e2ea43ce (diff) | |
[IMP] hr_timesheet: get rid of the "Service" product
The existence of the "Service" product caused issues when users would
eg. remove this product.
We allow user to create timsheets even if they dont have an employee associated
or if the product is missing on the employee. Those timesheets can still be
invoiced using the force product field of the wizard.
product_id is left blank if it cannot be deduced from the associated employee
and the amount is zero.
account_id is left blank we it not required anymore
journal_id is set the first general journal found.
21 files changed, 66 insertions, 154 deletions
diff --git a/addons/account/models/account_analytic_line.py b/addons/account/models/account_analytic_line.py index 5b8faf5a428..c340ad0b532 100644 --- a/addons/account/models/account_analytic_line.py +++ b/addons/account/models/account_analytic_line.py @@ -11,7 +11,8 @@ class AccountAnalyticLine(models.Model): product_uom_id = fields.Many2one('product.uom', string='Unit of Measure') product_id = fields.Many2one('product.product', string='Product') - general_account_id = fields.Many2one('account.account', string='Financial Account', required=True, ondelete='restrict', domain=[('deprecated', '=', False)]) + general_account_id = fields.Many2one('account.account', string='Financial Account', ondelete='restrict', + related='move_id.account_id', store=True, domain=[('deprecated', '=', False)]) move_id = fields.Many2one('account.move.line', string='Move Line', ondelete='cascade', index=True) journal_id = fields.Many2one('account.analytic.journal', string='Analytic Journal', required=True, ondelete='restrict', index=True) code = fields.Char(size=8) @@ -30,7 +31,7 @@ class AccountAnalyticLine(models.Model): if not journal_id: j_ids = self.pool.get('account.analytic.journal').search(cr, uid, [('type', '=', 'purchase')]) journal_id = j_ids and j_ids[0] or False - if not journal_id or not prod_id: + if not journal_id: return {} product_obj = self.pool.get('product.product') analytic_journal_obj = self.pool.get('account.analytic.journal') @@ -52,18 +53,10 @@ class AccountAnalyticLine(models.Model): a = prod.property_account_expense_id.id if not a: a = prod.categ_id.property_account_expense_categ_id.id - if not a: - raise UserError(_('There is no expense account defined ' \ - 'for this product: "%s" (id:%d).') % \ - (prod.name, prod.id,)) else: a = prod.property_account_income_id.id if not a: a = prod.categ_id.property_account_income_categ_id.id - if not a: - raise UserError(_('There is no income account defined ' \ - 'for this product: "%s" (id:%d).') % \ - (prod.name, prod_id,)) flag = False # Compute based on pricetype @@ -83,7 +76,12 @@ class AccountAnalyticLine(models.Model): # price_get() will respect a 'uom' in its context, in order # to return a default price for those units ctx['uom'] = unit - amount_unit = prod.price_get(pricetype.field, context=ctx)[prod.id] + amount_unit = prod.price_get(pricetype.field, context=ctx) + if amount_unit: + amount_unit = amount_unit[prod.id] + else: + amount_unit = 0.0 + amount = amount_unit * quantity or 0.0 cur_record = self.browse(cr, uid, id, context=context) currency = cur_record.exists() and cur_record.currency_id or prod.company_id.currency_id diff --git a/addons/delivery/test/delivery_cost.yml b/addons/delivery/test/delivery_cost.yml index 2022b844759..50177e59cf7 100644 --- a/addons/delivery/test/delivery_cost.yml +++ b/addons/delivery/test/delivery_cost.yml @@ -2,7 +2,7 @@ In order to test Carrier Cost, - Create sale order with Normal Delivery Charges -- +- !record {model: sale.order, id: sale_normal_delivery_charges}: partner_id: base.res_partner_18 partner_invoice_id: base.res_partner_18 @@ -48,7 +48,7 @@ self.create_invoice(cr, uid, [wiz_id], {"active_ids": ship_ids, "active_id": ship_ids[0]}) - Create one more sale order with Free Delivery Charges -- +- !record {model: sale.order, id: sale_free_delivery_charges}: partner_id: base.res_partner_7 partner_invoice_id: base.res_partner_address_13 @@ -57,7 +57,7 @@ order_policy: 'manual' order_line: - name: 'Service on demand' - product_id: product.product_product_consultant + product_id: product.product_product_1 product_uom_qty: 24 product_uos_qty: 24 product_uom: product.product_uom_hour diff --git a/addons/hr_timesheet/__openerp__.py b/addons/hr_timesheet/__openerp__.py index 62f0bec6009..3ba4eead94e 100644 --- a/addons/hr_timesheet/__openerp__.py +++ b/addons/hr_timesheet/__openerp__.py @@ -37,7 +37,6 @@ up a management by affair. ], 'test': [ '../account/test/account_minimal_test.xml', - 'test/hr_timesheet_data.xml', 'test/hr_timesheet_users.yml', ], 'installable': True, diff --git a/addons/hr_timesheet/hr_timesheet.py b/addons/hr_timesheet/hr_timesheet.py index a71dbd8b95b..d6687976657 100644 --- a/addons/hr_timesheet/hr_timesheet.py +++ b/addons/hr_timesheet/hr_timesheet.py @@ -14,12 +14,7 @@ class HrEmployee(models.Model): # We need the "or ..." because we need an empty recordset of the right type, 'False' is not enough. return self.env.ref('hr_timesheet.analytic_journal', raise_if_not_found=False) or self.env['account.analytic.journal'] - @api.model - def _get_default_employee_product(self): - # We need the "or ..." because we need an empty recordset of the right type, 'False' is not enough. - return self.env.ref('product.product_product_consultant', raise_if_not_found=False) or self.env['product.product'] - - product_id = fields.Many2one('product.product', 'Product', help="If you want to reinvoice working time of employees, link this employee to a service to determinate the cost price of the job.", default=_get_default_employee_product) + product_id = fields.Many2one('product.product', 'Product', help="If you want to reinvoice working time of employees, link this employee to a service to determinate the cost price of the job.") journal_id = fields.Many2one('account.analytic.journal', 'Analytic Journal', default=_get_default_analytic_journal) uom_id = fields.Many2one('product.uom', related='product_id.uom_id', string='Unit of Measure', store=True, readonly=True) @@ -48,7 +43,7 @@ class account_analytic_line(models.Model): if emp and emp.product_id.id: return emp.product_id.id else: - raise exceptions.ValidationError("This user or employee is not associated to a valid Product") + return None @api.model def _get_employee_unit(self, user_id=None): @@ -56,7 +51,7 @@ class account_analytic_line(models.Model): if emp and emp.product_id.uom_id.id: return emp.product_id.uom_id.id else: - raise exceptions.ValidationError("This user or employee is not associated to a Product with a valid Amount Type") + return None @api.model def _get_general_account(self, user_id=None): @@ -64,7 +59,7 @@ class account_analytic_line(models.Model): if emp and emp.product_id.categ_id.property_account_expense_categ_id.id: return emp.product_id.categ_id.property_account_expense_categ_id.id else: - raise exceptions.ValidationError("This user or employee is not associated to a Product with a valid Financial Account") + return None @api.model def _get_analytic_journal(self, user_id=None): @@ -72,24 +67,12 @@ class account_analytic_line(models.Model): if emp and emp.journal_id.id: return emp.journal_id.id else: - raise exceptions.ValidationError("This user or employee is not associated to a valid Journal ID") - - @api.one - @api.constrains('user_id') - def check_user_id(self): - if self.is_timesheet: - emp = self.env['hr.employee'].search([('user_id', '=', self.user_id.id)], limit=1) - if not emp: - raise exceptions.ValidationError("There is no employee defined for user " + self.user_id.name) + journal = self.env['account.analytic.journal'].search([('type', '=', 'general')], limit=1) + + if journal: + return journal.id else: - if not emp.journal_id.id: - raise exceptions.ValidationError("The employee " + emp.name + " is not associated to a valid Analytic Journal. Please define one for him or select another user.") - elif not emp.product_id: - raise exceptions.ValidationError("The employee " + emp.name + " is not associated to a valid Product. Please define one for him or select another user.") - elif not emp.product_id.uom_id.id: - raise exceptions.ValidationError("The employee " + emp.name + " is not associated to a valid Product Unit of Measure. Please define one for him or select another user.") - elif not emp.product_id.categ_id.property_account_expense_categ_id.id: - raise exceptions.ValidationError("The employee " + emp.name + " is not associated to a valid Financial Account. Please define one for him or select another user.") + return None @api.onchange('user_id') def V8_on_change_user_id(self): @@ -112,7 +95,7 @@ class account_analytic_line(models.Model): def on_change_unit_amount(self, cr, uid, id, prod_id, unit_amount, company_id, unit=False, journal_id=False, context=None): res = {'value': {}} - if prod_id and unit_amount: + if unit_amount: # find company company_id = self.pool.get('res.company')._company_default_get(cr, uid, 'account.analytic.line', context=context) r = super(account_analytic_line, self).on_change_unit_amount(cr, uid, id, prod_id, unit_amount, company_id, unit, journal_id, context=context) diff --git a/addons/hr_timesheet/hr_timesheet_data.xml b/addons/hr_timesheet/hr_timesheet_data.xml index 4fb03a7211e..35d6bfb0185 100644 --- a/addons/hr_timesheet/hr_timesheet_data.xml +++ b/addons/hr_timesheet/hr_timesheet_data.xml @@ -9,18 +9,5 @@ </record> - <!-- Service Product --> - <record id="product.product_product_consultant" model="product.product"> - <field name="sale_ok">True</field> - <field name="list_price">75.0</field> - <field name="standard_price">30.0</field> - <field name="uom_id" ref="product.product_uom_hour"/> - <field name="uom_po_id" ref="product.product_uom_hour"/> - <field name="name">Service</field> - <field name="categ_id" ref="product.product_category_all"/> - <field name="type">service</field> - <field name="image" type="base64" file="hr_timesheet/static/img/product_product_consultant-image.jpg"/> - </record> - </data> </openerp> diff --git a/addons/hr_timesheet/hr_timesheet_demo.xml b/addons/hr_timesheet/hr_timesheet_demo.xml index b512038e8da..faec6e306ca 100644 --- a/addons/hr_timesheet/hr_timesheet_demo.xml +++ b/addons/hr_timesheet/hr_timesheet_demo.xml @@ -1,15 +1,12 @@ <?xml version="1.0" encoding="utf-8"?> <openerp> <data noupdate="1"> - - - <!-- complete our example employee --> <record id="hr.employee_fp" model="hr.employee"> - <field name="product_id" ref="product.product_product_consultant"/> + <field name="product_id" ref="product.product_product_1"/> <field name="journal_id" ref="analytic_journal"/> </record> <record id="hr.employee_qdp" model="hr.employee"> - <field name="product_id" ref="product.product_product_consultant"/> + <field name="product_id" ref="product.product_product_1"/> <field name="journal_id" ref="analytic_journal"/> </record> @@ -25,10 +22,5 @@ <record id="analytic.analytic_super_product_trainings" model="account.analytic.account"> <field name="invoice_on_timesheets">True</field> </record> - - <record id="product.product_product_consultant" model="product.product"> - <field name="categ_id" ref="product.product_category_3"/> - </record> - </data> </openerp> diff --git a/addons/hr_timesheet/hr_timesheet_demo.yml b/addons/hr_timesheet/hr_timesheet_demo.yml index 011a302c135..530df19cf9e 100644 --- a/addons/hr_timesheet/hr_timesheet_demo.yml +++ b/addons/hr_timesheet/hr_timesheet_demo.yml @@ -10,7 +10,7 @@ 'user_id': ref('base.user_root'), 'date': time.strftime('%Y-%m-%d'), 'unit_amount': 2.00, - 'product_id': ref('product.product_product_consultant'), + 'product_id': ref('product.product_product_1'), 'product_uom_id': ref('product.product_uom_hour'), 'account_id': ref('analytic.analytic_administratif'), 'amount': -60.00, @@ -23,7 +23,7 @@ 'user_id': ref('base.user_root'), 'date': time.strftime('%Y-%m-%d'), 'unit_amount': 1.00, - 'product_id': ref('product.product_product_consultant'), + 'product_id': ref('product.product_product_1'), 'product_uom_id': ref('product.product_uom_hour'), 'account_id': ref('analytic.analytic_administratif'), 'amount': -30.00, @@ -36,7 +36,7 @@ 'user_id': ref('base.user_root'), 'date': time.strftime('%Y-%m-%d'), 'unit_amount': 3.00, - 'product_id': ref('product.product_product_consultant'), + 'product_id': ref('product.product_product_1'), 'product_uom_id': ref('product.product_uom_hour'), 'account_id': ref('analytic.analytic_administratif'), 'amount': -90.00, @@ -49,7 +49,7 @@ 'user_id': ref('base.user_root'), 'date': time.strftime('%Y-%m-%d'), 'unit_amount': 1.00, - 'product_id': ref('product.product_product_consultant'), + 'product_id': ref('product.product_product_1'), 'product_uom_id': ref('product.product_uom_hour'), 'account_id': ref('analytic.analytic_administratif'), 'amount': -30.00, @@ -62,7 +62,7 @@ 'user_id': ref('base.user_root'), 'date': time.strftime('%Y-%m-%d'), 'unit_amount': 1.00, - 'product_id': ref('product.product_product_consultant'), + 'product_id': ref('product.product_product_1'), 'product_uom_id': ref('product.product_uom_hour'), 'account_id': ref('analytic.analytic_administratif'), 'amount': -30.00, diff --git a/addons/hr_timesheet/hr_timesheet_view.xml b/addons/hr_timesheet/hr_timesheet_view.xml index 1fa91bc1828..cd3a3f0b91b 100644 --- a/addons/hr_timesheet/hr_timesheet_view.xml +++ b/addons/hr_timesheet/hr_timesheet_view.xml @@ -6,7 +6,7 @@ <field name="name">account.analytic.line.tree</field> <field name="model">account.analytic.line</field> <field name="arch" type="xml"> - <tree editable="top" string="Timesheet Activities"> + <tree editable="top" string="Timesheet Activities"> <field name="date"/> <field name="user_id" required="1" options='{"no_open": True}' context="{'default_groups_ref': ['base.group_user']}"/> @@ -17,7 +17,7 @@ <field name="journal_id" invisible="1"/> <field name="amount" sum="Total cost" invisible="1"/> <field name="general_account_id" invisible="1"/> - <field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id)" required="1" domain="[('type','=','service')]" invisible="1"/> + <field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id)" domain="[('type','=','service')]" invisible="1"/> <field name="is_timesheet" invisible="1"/> </tree> </field> @@ -43,7 +43,7 @@ <page string="Information"> <group> <group string="Product"> - <field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id)" required="1" domain="[('type','=','service')]"/> + <field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id)" domain="[('type','=','service')]"/> <label string="Duration" for="unit_amount"/> <div> <field name="unit_amount" class="oe_inline" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id)"/> @@ -108,7 +108,7 @@ </field> </record> - + <record id="account_analytic_account_timesheet_form" model="ir.ui.view"> <field name="name">account.analytic.account.invoice.form</field> <field name="model">account.analytic.account</field> @@ -119,12 +119,12 @@ <label for="invoice_on_timesheets"/> </xpath> <div name="button_box" position="inside"> - <button class="oe_stat_button" type="action" name="%(act_analytic_cost_revenue)d" + <button class="oe_stat_button" type="action" name="%(act_analytic_cost_revenue)d" icon="fa-usd" string="Cost/Revenue" widget="statinfo" attrs="{'invisible': [('type','=','template')]}"/> </div> </field> </record> - + <record id="act_hr_timesheet_accounts_form" model="ir.actions.act_window"> <field name="name">Timesheet Accounts</field> <field name="type">ir.actions.act_window</field> @@ -137,7 +137,7 @@ <menuitem name="Configuration" id="menu_hr_timesheet_config" sequence="100" parent="hr_attendance.timesheet_menu_root" groups="base.group_configuration" action="act_hr_timesheet_accounts_form"/> - + <record id="act_hr_timesheet_line_evry1_all_form" model="ir.actions.act_window"> <field name="name">Activities</field> <field name="res_model">account.analytic.line</field> diff --git a/addons/hr_timesheet/test/hr_timesheet_data.xml b/addons/hr_timesheet/test/hr_timesheet_data.xml deleted file mode 100644 index c9ad0322dc0..00000000000 --- a/addons/hr_timesheet/test/hr_timesheet_data.xml +++ /dev/null @@ -1,18 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<openerp> -<data> - - <record id="product.product_product_consultant_test" model="product.product"> - <field name="sale_ok">True</field> - <field name="list_price">75.0</field> - <field name="standard_price">30.0</field> - <field name="uom_id" ref="product.product_uom_hour"/> - <field name="uom_po_id" ref="product.product_uom_hour"/> - <field name="name">Service - Test</field> - <field name="categ_id" ref="product.product_category_all"/> - <field name="type">service</field> - <field name="image" type="base64" file="hr_timesheet/static/img/product_product_consultant-image.jpg"/> - </record> - -</data> -</openerp> diff --git a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py index 51aa1e75408..058137f5b71 100644 --- a/addons/hr_timesheet_invoice/hr_timesheet_invoice.py +++ b/addons/hr_timesheet_invoice/hr_timesheet_invoice.py @@ -270,6 +270,9 @@ class account_analytic_line(osv.osv): if not analytic_line.to_invoice: raise UserError(_('Trying to invoice non invoiceable line for %s.') % (analytic_line.product_id.name)) + if not analytic_line.product_id and not data['product']: + raise UserError(_('No product associated with %s, force a product.') % (analytic_line.name)) + key = (analytic_line.product_id.id, analytic_line.product_uom_id.id, analytic_line.user_id.id, diff --git a/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml b/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml index 009a5b1cd12..a63478db8df 100644 --- a/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml +++ b/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice.yml @@ -9,7 +9,7 @@ general_account_id: a_expense journal_id: hr_timesheet.analytic_journal name: develop yaml for hr module - product_id: product.product_product_consultant + product_id: product.product_product_1 product_uom_id: product.product_uom_hour to_invoice: hr_timesheet_invoice.timesheet_invoice_factor2 unit_amount: 5.00 @@ -49,13 +49,13 @@ code: "I000" user_type_id: "account.data_account_type_revenue" tax_ids: [tax10] -- - I set the account as property_account_income_id on the product and I set the tax on the product -- - !record {model: product.product, id: product.product_product_consultant, view: False}: +- + I set the account as property_account_income_id on the product and I set the tax on the product +- + !record {model: product.product, id: product.product_product_1, view: False}: property_account_income_id: account_income_i000 uom_id: product.product_uom_hour - taxes_id: [tax10] + taxes_id: [tax10] list_price: 75 - I create invoice on analytic Line using "Invoice analytic Line" wizard. @@ -64,7 +64,7 @@ date: 1 name: 1 price: 1 - product: product.product_product_consultant + product: product.product_product_1 time: 1 - I click on "Create Invoice" button of "Invoice analytic Line" wizard to create invoice. @@ -129,7 +129,7 @@ general_account_id: a_expense journal_id: hr_timesheet.analytic_journal name: sales module extension - product_id: product.product_product_consultant + product_id: product.product_product_1 product_uom_id: product.product_uom_hour to_invoice: hr_timesheet_invoice.timesheet_invoice_factor2 unit_amount: 5.00 @@ -142,7 +142,7 @@ general_account_id: a_expense journal_id: hr_timesheet.analytic_journal name: template design - product_id: product.product_product_consultant + product_id: product.product_product_1 product_uom_id: product.product_uom_hour to_invoice: hr_timesheet_invoice.timesheet_invoice_factor2 unit_amount: 5.00 @@ -152,7 +152,7 @@ !record {model: hr.timesheet.invoice.create, id: hr_timesheet_invoice_create_1}: date: 1 name: 1 - product: product.product_product_consultant + product: product.product_product_1 time: 1 group_by_partner: 1 - diff --git a/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice_no_prod_tax.yml b/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice_no_prod_tax.yml index 23dc1fa75c3..40363ba1d14 100644 --- a/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice_no_prod_tax.yml +++ b/addons/hr_timesheet_invoice/test/test_hr_timesheet_invoice_no_prod_tax.yml @@ -9,7 +9,7 @@ general_account_id: a_expense journal_id: hr_timesheet.analytic_journal name: develop yaml for hr module - product_id: product.product_product_consultant + product_id: product.product_product_1 product_uom_id: product.product_uom_hour to_invoice: hr_timesheet_invoice.timesheet_invoice_factor2 unit_amount: 5.00 @@ -51,7 +51,7 @@ - I set the account as property_account_income_id on the product and I set no tax on the product (so default tax from the account will be used) - - !record {model: product.product, id: product.product_product_consultant, view: False}: + !record {model: product.product, id: product.product_product_1, view: False}: property_account_income_id: account_income_i000 uom_id: product.product_uom_hour taxes_id: [] @@ -63,7 +63,7 @@ date: 1 name: 1 price: 1 - product: product.product_product_consultant + product: product.product_product_1 time: 1 - I click on "Create Invoice" button of "Invoice analytic Line" wizard to create invoice. @@ -91,7 +91,7 @@ invoice_ids = invoice_obj.search(cr, uid, [('partner_id', '=', partner), ('origin', '=', 'test-hrtsic0_id_'+str( ref("hr_timesheet_invoice_create_0")) + '_aaldyfhrm1_id_'+str( ref("hr_timesheet_invoice.account_analytic_line_developyamlforhrmodule1") )) ]) - + invoice_id = invoice_obj.browse(cr, uid, invoice_ids)[0] for invoice in invoice_id.invoice_line_ids: diff --git a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py index 6cd0c3ba796..139ba39cb45 100644 --- a/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py +++ b/addons/hr_timesheet_invoice/wizard/hr_timesheet_invoice_create.py @@ -15,7 +15,7 @@ class hr_timesheet_invoice_create(osv.osv_memory): 'time': fields.boolean('Time spent', help='The time of each work done will be displayed on the invoice'), 'name': fields.boolean('Description', help='The detail of each work done will be displayed on the invoice'), 'price': fields.boolean('Cost', help='The cost of each work done will be displayed on the invoice. You probably don\'t want to check this'), - 'product': fields.many2one('product.product', 'Force Product', help='Fill this field only if you want to force to use a specific product. Keep empty to use the real product that comes from the cost.'), + 'product': fields.many2one('product.product', 'Force Product', help='Fill this field only if you want to force the use a specific product. Keep empty to use the real product that comes from the cost.'), 'group_by_partner': fields.boolean('Group by Partner', help='If this box is checked, the system will group invoices by customer.'), } diff --git a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py index fee198150cc..30c09356495 100644 --- a/addons/hr_timesheet_sheet/hr_timesheet_sheet.py +++ b/addons/hr_timesheet_sheet/hr_timesheet_sheet.py @@ -52,8 +52,6 @@ class hr_timesheet_sheet(osv.osv): if 'employee_id' in vals: if not self.pool.get('hr.employee').browse(cr, uid, vals['employee_id'], context=context).user_id: raise UserError(_('In order to create a timesheet for this employee, you must link him/her to a user.')) - if not self.pool.get('hr.employee').browse(cr, uid, vals['employee_id'], context=context).product_id: - raise UserError(_('In order to create a timesheet for this employee, you must link the employee to a product, like \'Consultant\'.')) if not self.pool.get('hr.employee').browse(cr, uid, vals['employee_id'], context=context).journal_id: raise UserError(_('In order to create a timesheet for this employee, you must assign an analytic journal to the employee, like \'Timesheet Journal\'.')) if vals.get('attendances_ids'): @@ -97,7 +95,7 @@ class hr_timesheet_sheet(osv.osv): date_attendances.append((1, name, att_tuple)) elif att_tuple[0] in [2,3]: date_attendances.append((0, self.pool['hr.attendance'].browse(cr, uid, att_tuple[1]).name, att_tuple)) - else: + else: date_attendances.append((0, False, att_tuple)) date_attendances.sort() return [att[2] for att in date_attendances] @@ -120,7 +118,7 @@ class hr_timesheet_sheet(osv.osv): for sheet in self.browse(cr, uid, ids, context=context): if sheet.employee_id.id not in employee_ids: employee_ids.append(sheet.employee_id.id) return hr_employee.attendance_action_change(cr, uid, employee_ids, context=context) - + def _count_attendances(self, cr, uid, ids, field_name, arg, context=None): res = dict.fromkeys(ids, 0) attendances_groups = self.pool['hr.attendance'].read_group(cr, uid, [('sheet_id' , 'in' , ids)], ['sheet_id'], 'sheet_id', context=context) diff --git a/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml b/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml index 9363454df09..df9383af192 100644 --- a/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml +++ b/addons/hr_timesheet_sheet/test/test_hr_timesheet_sheet.yml @@ -45,7 +45,7 @@ user_id: base.user_demo unit_amount: 6.00 amount: -90.00 - product_id: product.product_product_consultant + product_id: product.product_product_1 general_account_id: a_expense journal_id: hr_timesheet.analytic_journal - @@ -74,7 +74,7 @@ unit_amount: 2.00 user_id: base.user_demo amount: -90.00 - product_id: product.product_product_consultant + product_id: product.product_product_1 general_account_id: a_expense journal_id: hr_timesheet.analytic_journal - diff --git a/addons/hr_timesheet_sheet/wizard/hr_timesheet_current.py b/addons/hr_timesheet_sheet/wizard/hr_timesheet_current.py index 419d4901d9c..a0cec9fab48 100644 --- a/addons/hr_timesheet_sheet/wizard/hr_timesheet_current.py +++ b/addons/hr_timesheet_sheet/wizard/hr_timesheet_current.py @@ -16,9 +16,6 @@ class hr_timesheet_current_open(osv.osv_memory): context = {} view_type = 'form,tree' - user_ids = self.pool.get('hr.employee').search(cr, uid, [('user_id','=',uid)], context=context) - if not len(user_ids): - raise UserError(_('Please create an employee and associate it with this user.')) ids = ts.search(cr, uid, [('user_id','=',uid),('state','in',('draft','new')),('date_from','<=',time.strftime('%Y-%m-%d')), ('date_to','>=',time.strftime('%Y-%m-%d'))], context=context) if len(ids) > 1: diff --git a/addons/project_timesheet/project_timesheet_demo.xml b/addons/project_timesheet/project_timesheet_demo.xml index 33d30a94191..78aade68999 100644 --- a/addons/project_timesheet/project_timesheet_demo.xml +++ b/addons/project_timesheet/project_timesheet_demo.xml @@ -3,12 +3,11 @@ <data noupdate="1"> <!-- Example employee --> <record id="hr.employee_qdp" model="hr.employee"> - <field name="product_id" ref="product.product_product_consultant"/> + <field name="product_id" ref="product.product_product_2"/> <field name="journal_id" ref="hr_timesheet.analytic_journal"/> </record> <record id="hr.employee_al" model="hr.employee"> - <field name="product_id" ref="product.product_product_consultant"/> <field name="journal_id" ref="hr_timesheet.analytic_journal"/> </record> @@ -16,7 +15,6 @@ <field name="name">Lisa Jongejans</field> <field name="calendar_id" ref="resource.timesheet_group1"/> <field name="category_ids" eval="[(6, 0, [ref('hr.employee_category_4')])]"/> - <field name="product_id" ref="product.product_product_consultant"/> <field name="journal_id" ref="hr_timesheet.analytic_journal"/> <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">+3282623500</field> @@ -27,21 +25,19 @@ <field name="name">Martin Lawrence</field> <field name="calendar_id" ref="resource.timesheet_group1"/> <field name="category_ids" eval="[(6, 0, [ref('hr.employee_category_4')])]"/> - <field name="product_id" ref="product.product_product_consultant"/> + <field name="product_id" ref="product.product_product_2"/> <field name="journal_id" ref="hr_timesheet.analytic_journal"/> </record> <record id="hr.employee_jth" model="hr.employee"> <field name="name">Jimmy Kosikin</field> <field name="calendar_id" ref="resource.timesheet_group1"/> <field name="category_ids" eval="[(6, 0, [ref('hr.employee_category_4')])]"/> - <field name="product_id" ref="product.product_product_consultant"/> <field name="journal_id" ref="hr_timesheet.analytic_journal"/> </record> <record id="hr.employee7" model="hr.employee"> <field name="name">Alice Englert</field> <field name="calendar_id" ref="resource.timesheet_group1"/> <field name="category_ids" eval="[(6, 0, [ref('hr.employee_category_4')])]"/> - <field name="product_id" ref="product.product_product_consultant"/> <field name="journal_id" ref="hr_timesheet.analytic_journal"/> <field name="work_location">Building 1, Second Floor</field> <field name="work_phone">+3282823500</field> @@ -52,7 +48,6 @@ </record> <record id="hr.employee_fp" model="hr.employee"> <field name="calendar_id" ref="resource.timesheet_group1"/> - <field name="product_id" ref="product.product_product_consultant"/> <field name="journal_id" ref="hr_timesheet.analytic_journal"/> </record> diff --git a/addons/project_timesheet/project_timesheet_view.xml b/addons/project_timesheet/project_timesheet_view.xml index 564d6934a33..44c77756cbb 100644 --- a/addons/project_timesheet/project_timesheet_view.xml +++ b/addons/project_timesheet/project_timesheet_view.xml @@ -114,7 +114,7 @@ </p> </field> </record> - + <!-- Time Tracking menu in project Management --> @@ -168,7 +168,7 @@ <field name="journal_id" invisible="1"/> <field name="amount" sum="Total cost" invisible="1"/> <field name="general_account_id" invisible="1"/> - <field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id, context)" required="1" domain="[('type','=','service')]" invisible="1"/> + <field name="product_id" on_change="on_change_unit_amount(product_id, unit_amount, False, product_uom_id,journal_id, context)" domain="[('type','=','service')]" invisible="1"/> <field name="is_timesheet" invisible="1"/> </tree> </field> diff --git a/addons/sale_contract/models/res_config.py b/addons/sale_contract/models/res_config.py index 30f75853a74..2de8c3ea7d5 100644 --- a/addons/sale_contract/models/res_config.py +++ b/addons/sale_contract/models/res_config.py @@ -21,10 +21,6 @@ class sale_configuration(osv.osv_memory): if res.get('module_project'): user = self.pool.get('res.users').browse(cr, uid, uid, context) res['time_unit'] = user.company_id.project_time_mode_id.id - else: - product = ir_model_data.xmlid_to_object(cr, uid, 'product.product_product_consultant') - if product and product.exists(): - res['time_unit'] = product.uom_id.id res['timesheet'] = res.get('module_sale_contract') return res @@ -32,14 +28,6 @@ class sale_configuration(osv.osv_memory): ir_model_data = self.pool.get('ir.model.data') wizard = self.browse(cr, uid, ids)[0] - if wizard.time_unit: - product = ir_model_data.xmlid_to_object(cr, uid, 'product.product_product_consultant') - if product and product.exists(): - product.write({'uom_id': wizard.time_unit.id, 'uom_po_id': wizard.time_unit.id}) - else: - _logger.info("Product with xml_id 'product.product_product_consultant' not found, UoMs not updated!") - raise UserError(_("Product with xml_id 'product.product_product_consultant' not found, UoMs not updated!")) - if wizard.module_project and wizard.time_unit: user = self.pool.get('res.users').browse(cr, uid, uid, context) user.company_id.write({'project_time_mode_id': wizard.time_unit.id}) diff --git a/addons/sale_contract/test/account_analytic_analysis.yml b/addons/sale_contract/test/account_analytic_analysis.yml index 00476a6f003..69950269fb8 100644 --- a/addons/sale_contract/test/account_analytic_analysis.yml +++ b/addons/sale_contract/test/account_analytic_analysis.yml @@ -1,5 +1,5 @@ - - In order to test Contract Recurrent Invoice I create a new Contract Template + In order to test Contract Recurrent Invoice I create a new Contract Template - !record {model: account.analytic.account, id: contract_template}: name: Maintenance of Servers @@ -10,9 +10,9 @@ recurring_interval : 1 recurring_invoice_line_ids: - quantity: 2.0 - price_unit: 75.0 + price_unit: 30.75 name: Database Administration - product_id: product.product_product_consultant + product_id: product.product_product_1 uom_id: product.product_uom_hour - I create a contract based on this template @@ -43,4 +43,4 @@ ids = self.search(cr, uid, [('invoice_line.analytic_account_id','=',aid)], context=context) assert len(ids)>=1, 'No invoice created for the contract' for invoice in self.browse(cr, uid, ids,context=context): - assert float_compare(invoice.amount_untaxed, 150.0, precision_digits=2) == 0, "The invoice total is different than 150!" + assert float_compare(invoice.amount_untaxed, 61.5, precision_digits=2) == 0, "The invoice total is different than 61.5!" diff --git a/addons/sale_contract/views/res_config_view.xml b/addons/sale_contract/views/res_config_view.xml index 9f9b778d308..e65f22aa4e5 100644 --- a/addons/sale_contract/views/res_config_view.xml +++ b/addons/sale_contract/views/res_config_view.xml @@ -13,18 +13,8 @@ <label for="group_template_required"/> </div> </xpath> - <group name="default_options" position="attributes"> - <attribute name="invisible">0</attribute> - </group> - <xpath expr="//div[@name='div_default_options']" position="inside"> - <div name='time_unit' attrs="{'required':[('module_sale_contract','=',True)]}"> - <label for="time_unit"/> - <field name="time_unit" domain="[('category_id.name','=','Working Time')]" class="oe_inline"/> - </div> - </xpath> </field> </record> </data> </openerp> - |
