Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12.0][FIX] Improved code of stage create method. #643

Open
wants to merge 1 commit into
base: 12.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions fieldservice/models/fsm_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ def _default_team_ids(self):
stage_type = fields.Selection([('order', 'Order'),
('equipment', 'Equipment'),
('location', 'Location'),
('worker', 'Worker')], 'Type',
required=True)
('worker', 'Worker')], 'Type', require=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid this is incorrect, required is the correct field attribute.
Is the goal to remove the required attribute?

company_id = fields.Many2one(
'res.company', string='Company',
default=lambda self: self.env.user.company_id.id)
Expand All @@ -73,8 +72,8 @@ def get_color_information(self):
def create(self, vals):
stages = self.env['fsm.stage'].search([])
for stage in stages:
if stage.stage_type == vals['stage_type'] and \
stage.sequence == vals['sequence']:
if stage.stage_type == vals.get('stage_type') and \
stage.sequence == vals.get('sequence'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

raise ValidationError(_("Cannot create FSM Stage because "
"it has the same Type and Sequence "
"of an existing FSM Stage."))
Expand Down
3 changes: 2 additions & 1 deletion fieldservice/views/fsm_team.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<field name="name">Orders</field>
<field name="res_model">fsm.order</field>
<field name="view_mode">kanban,timeline,tree,form,calendar</field>
<field name="context">{'default_team_id': active_id}</field>
<field name="context">{'default_team_id': active_id,
'default_stage_type':'order'}</field>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
'default_stage_type':'order'}</field>
'default_stage_type': 'order'}</field>

<field name="domain">[('team_id', '=', active_id)]</field>
</record>

Expand Down