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

Conversation

rutul-serpentcs
Copy link

When I create stage from Field Service >> Dashboard >> Team >> Orders kanban view I got an error.

Teams-Odoo

@OCA-git-bot
Copy link
Contributor

Hi @max3903, @wolfhall,
some modules you are maintaining are being modified, check this out!

Copy link
Sponsor Contributor

@brian10048 brian10048 left a comment

Choose a reason for hiding this comment

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

@rutul-serpentcs
This fixes the original error you presented.
However there is still an issue creating the stage from Kanban view

The operation cannot be completed:
- Create/update: a mandatory field is not set.
- Delete: another model requires the record being deleted. If possible, archive it instead.

Model: Field Service Stage (fsm.stage), Field: Type (stage_type) 

stage_type field needs to be set

@rutul-serpentcs
Copy link
Author

@rutul-serpentcs
This fixes the original error you presented.
However there is still an issue creating the stage from Kanban view

The operation cannot be completed:
- Create/update: a mandatory field is not set.
- Delete: another model requires the record being deleted. If possible, archive it instead.

Model: Field Service Stage (fsm.stage), Field: Type (stage_type) 

stage_type field needs to be set

@brian10048 Done, Can you please review it again?

@brian10048
Copy link
Sponsor Contributor

@rutul-serpentcs - It allows to create the stage, but a new bug is introduced when we create a stage that has an undefined stage type. When you go back to the orders kanban view, the stage recently created will not be displayed.

Can you revert the recent change and keep the stage_type required in python? Then, instead can you use the context to set the correct stage_type based on the view

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

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

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
Sponsor Member

Choose a reason for hiding this comment

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

👍

@github-actions
Copy link

There hasn't been any activity on this pull request in the past 4 months, so it has been marked as stale and it will be closed automatically if no further activity occurs in the next 30 days.
If you want this PR to never become stale, please ask a PSC member to apply the "no stale" label.

@github-actions github-actions bot added the stale PR/Issue without recent activity, it'll be soon closed automatically. label May 15, 2022
@brian10048 brian10048 added no stale Use this label to prevent the automated stale action from closing this PR/Issue. and removed stale PR/Issue without recent activity, it'll be soon closed automatically. labels May 24, 2022
@max3903 max3903 assigned max3903 and unassigned rutul-serpentcs Oct 20, 2022
Copy link
Sponsor Member

@max3903 max3903 left a comment

Choose a reason for hiding this comment

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

Please attend the comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs fixing no stale Use this label to prevent the automated stale action from closing this PR/Issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants