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

[9.0] [MIG] project_task_materials_stock module #208

Merged
merged 4 commits into from
Jan 10, 2017

Conversation

cubells
Copy link
Sponsor Member

@cubells cubells commented Dec 18, 2016

  • Updated README
  • Updated views
  • Updated tests

cc @Tecnativa

@cubells cubells force-pushed the 9.0-mig-project_task_materials_stock branch from c0bb675 to d94fca2 Compare December 18, 2016 18:13
@pedrobaeza pedrobaeza force-pushed the 9.0-mig-project_task_materials_stock branch from d94fca2 to ba7de77 Compare December 18, 2016 23:01
Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

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

Minor things to change

=============

#. If you are a project manager, go to Project > Configuration > Stages and
check option 'Consume Material' in Task Stage to generate a stock move when
Copy link
Member

Choose a reason for hiding this comment

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

Indent these lines 3 spaces to get a correct visualization


#. Go to a task, edit, and add materials to be consumed on tab "Materials".
#. Move task to an stage on consume material are activated and moves and
analytic lines will be created.
Copy link
Member

Choose a reason for hiding this comment

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

Indent this

@@ -0,0 +1,62 @@
# Translation of Odoo Server.
Copy link
Member

Choose a reason for hiding this comment

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

Remove this file

@pedrobaeza pedrobaeza mentioned this pull request Dec 18, 2016
25 tasks
Copy link
Member

@pedrobaeza pedrobaeza left a comment

Choose a reason for hiding this comment

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

Please squash your migration commits. Runbot will be correct when the dependency is merged.

@cubells cubells force-pushed the 9.0-mig-project_task_materials_stock branch from ae30140 to cfab78f Compare December 21, 2016 11:09
@pedrobaeza pedrobaeza force-pushed the 9.0-mig-project_task_materials_stock branch from cfab78f to 9bb6b53 Compare December 23, 2016 20:30
@pedrobaeza
Copy link
Member

@cubells, can you improve tests for avoiding dropping coverage?

@cubells cubells force-pushed the 9.0-mig-project_task_materials_stock branch 3 times, most recently from 2e7c1ff to b19cdb1 Compare December 25, 2016 12:19
Copy link
Member

@yajo yajo left a comment

Choose a reason for hiding this comment

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

Some not required implementation notes, but at least please give your thoughts on them.

_inherit = 'project.task.type'

consume_material = fields.Boolean(
string='Consume Material',
Copy link
Member

Choose a reason for hiding this comment

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

Since the string equals the field name, you don't need it.


consume_material = fields.Boolean(
string='Consume Material',
help="If you mark this check, when a task goes to this state,"
Copy link
Member

Choose a reason for hiding this comment

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

Add a space at the end of the string, or it will join without it.

elif task.stock_move_ids.filtered(lambda r: r.state == 'assigned'):
task.stock_state = 'assigned'
elif task.stock_move_ids.filtered(lambda r: r.state == 'done'):
task.stock_state = 'done'
Copy link
Member

Choose a reason for hiding this comment

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

Probably this would be faster & shorter:

if not task.stock_move_ids:
    task.stock_state = 'pending'
else:
    states = task.mapped("stock_move_ids.state")
    for ("confirmed", "assigned", "done") as state:
        if state in states:
            task.stock_state = state
            break

if not moves_done:
moves.filtered(lambda r: r.state == 'assigned').do_unreserve()
moves.filtered(
lambda r: r.state in ['waiting', 'confirmed', 'assigned']
Copy link
Member

Choose a reason for hiding this comment

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

Use a set instead of a list, it's way faster in this case.

task.material_ids.create_analytic_line()
else:
if task.unlink_stock_move():
if any(task.material_ids.mapped(
Copy link
Member

Choose a reason for hiding this comment

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

You don't need any here AFAIK.


@api.multi
def action_assign(self):
self.mapped('stock_move_ids').action_assign()
Copy link
Member

Choose a reason for hiding this comment

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

Don't you need to return it? 🤔

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

It's not needed because this method is introduced in this module


@api.multi
def action_done(self):
self.mapped('stock_move_ids').action_done()
Copy link
Member

Choose a reason for hiding this comment

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

Don't you need to return it? 🤔

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

It's not needed because this method is introduced in this module

comodel_name='stock.move', string='Stock Move')
analytic_line_id = fields.Many2one(
comodel_name='account.analytic.line', string='Analytic Line')
product_uom = fields.Many2one(
Copy link
Member

Choose a reason for hiding this comment

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

Add _id suffix. And possibly an oldname if this was like this in v8.

ctx['uom'] = self.product_uom.id
# Compute based on pricetype
amount_unit = \
self.product_id.with_context(ctx).price_get(
Copy link
Member

Choose a reason for hiding this comment

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

Better do self.product_id.with_context(uom=self.product_uom.id).price_get( and remove those ctx lines above.

@dreispt
Copy link
Sponsor Member

dreispt commented Jan 6, 2017

Status?

@cubells cubells force-pushed the 9.0-mig-project_task_materials_stock branch 2 times, most recently from 6f3e4a3 to 4e69a0b Compare January 7, 2017 09:26
@cubells
Copy link
Sponsor Member Author

cubells commented Jan 7, 2017

All is done @dreispt @pedrobaeza @yajo

@pedrobaeza pedrobaeza force-pushed the 9.0-mig-project_task_materials_stock branch from 4e69a0b to 052df80 Compare January 7, 2017 15:48
Copy link
Member

@yajo yajo left a comment

Choose a reason for hiding this comment

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

Code review OK, just a little question...

<page string="Products">
<field name="material_ids" attrs="{'readonly':[('stock_state','!=', 'pending')]}">
<tree string="Materials used" editable="top">
<field name="product_id" domain="[('type', 'in', ['consu', 'product'])]"/>
Copy link
Member

Choose a reason for hiding this comment

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

Would it make sense under some scenarios to be able to put other product types? Such as considering the task has consumed a service product?

Copy link
Member

Choose a reason for hiding this comment

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

@carlosdauden, do you remember why we finally discard that option?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

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

Consume action create an stock move and stock move only can be generated with products that not are services.
That's the reason.

@pedrobaeza pedrobaeza merged commit 3cee700 into OCA:9.0 Jan 10, 2017
@pedrobaeza pedrobaeza deleted the 9.0-mig-project_task_materials_stock branch January 10, 2017 08:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants