Multiple selection of companies in timesheet cost sync wizard.

This commit refs #3479
This commit is contained in:
Javier Uribe 2017-11-29 10:54:39 +01:00
parent 00820f00f3
commit ac9ed13f92
3 changed files with 22 additions and 1 deletions

View File

@ -26,6 +26,10 @@ msgctxt "field:timesheet.line.sync_cost.start,costless:"
msgid "Only costless"
msgstr "Sólo sin coste"
msgctxt "field:timesheet.line.sync_cost.start,companies:"
msgid "Companies"
msgstr "Empresas"
msgctxt "help:timesheet.line.sync_cost.start,costless:"
msgid "Will compute cost only for lines without it."
msgstr "Calculará el coste sólo para líneas sin coste."

View File

@ -3,6 +3,7 @@
from trytond.model import ModelView
from trytond.pool import Pool
from trytond.model import fields
from trytond.pyson import Eval
from trytond.wizard import Button, StateTransition, StateView, Wizard
from trytond.transaction import Transaction
@ -19,6 +20,20 @@ class TimesheetSyncCostStart(ModelView):
employee = fields.Many2One('company.employee', 'Employee')
costless = fields.Boolean('Only costless',
help='Will compute cost only for lines without it.')
companies = fields.One2Many('company.company', None,
'Companies',
domain=[
('parent', 'child_of', Eval('context', {}).get('company'),
'parent')])
@staticmethod
def default_companies():
Company = Pool().get('company.company')
companies = Company.search([
('parent', 'child_of', Transaction().context.get('company'),
'parent')
])
return map(int, companies)
@staticmethod
def default_start_date():
@ -45,7 +60,7 @@ class TimesheetSyncCost(Wizard):
Line = pool.get('timesheet.line')
_domain = [
('company', '=', Transaction().context['company']),
('company', 'in', self.start.companies),
('date', '>=', self.start.start_date),
]
if getattr(self.start, 'end_date', None):

View File

@ -12,4 +12,6 @@
<field name="employee"/>
<label name="costless"/>
<field name="costless"/>
<newline/>
<field name="companies" colspan="4" widget="many2many"/>
</form>