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

Migration of purchase_request_to_rfq to 10.0 #287

Merged
merged 63 commits into from
May 15, 2017

Conversation

adrienpeiffer
Copy link
Contributor

@adrienpeiffer adrienpeiffer commented Oct 14, 2016

  • Forward modification on purchase_request_to_rfq after merge in 9.0

@adrienpeiffer adrienpeiffer force-pushed the 10-mig-purchase_request_to_rfq-ape branch from b8de42e to af32153 Compare October 14, 2016 09:07
@pedrobaeza pedrobaeza mentioned this pull request Oct 15, 2016
38 tasks
"""
request_line_ids = []
for line in self:
request_line_ids += line.purchase_request_lines.ids

Choose a reason for hiding this comment

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

request_line_ids = line.mapped('purchase_request_lines').ids

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean self.mapped('purchase_request_lines').ids ?

Choose a reason for hiding this comment

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

Oops, yes, sorry :)

def _compute_purchased_qty(self):
for rec in self:
rec.purchased_qty = sum(rec.purchase_lines.filtered(
lambda x: x.state != 'cancel').mapped('product_qty'))

Choose a reason for hiding this comment

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

Use the compute_quantity method to convert all quantities to the same UoM before summing values.

if picking.picking_type_id.code != 'incoming':
continue
for move in picking.move_lines:
if move.purchase_line_id:

Choose a reason for hiding this comment

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

The if statement is useless here.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

@sylvain-garancher Why? purchase_line_id it is used within.

date_order_str = datetime.strptime(
fields.datetime.now().strftime(DEFAULT_SERVER_DATETIME_FORMAT),
DEFAULT_SERVER_DATETIME_FORMAT).\
strftime(DEFAULT_SERVER_DATE_FORMAT)

Choose a reason for hiding this comment

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

date_order_str = fields.Date.today() ?
Or date_order_str = fields.Date.context_today() ?

res.append(purchase.id)

return {
'domain': "[('id','in', ["+','.join(map(str, res))+"])]",

Choose a reason for hiding this comment

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

'domain': str([('id', 'in', res)]),

@adrienpeiffer
Copy link
Contributor Author

I added some fixes/improvements in my last commits

@JordiBForgeFlow
Copy link
Sponsor Member

@adrienpeiffer This PR from 9.0 should be moved to 10.0 #291 once it's merged.

@adrienpeiffer
Copy link
Contributor Author

@jbeficent this is strange ... I have never seen this problem

@Garamotte
Copy link

@adrienpeiffer The update method allows to change the value of multiple fields at a time, but only allows a single record, so using it after filtered is not safe.

@JordiBForgeFlow
Copy link
Sponsor Member

@adrienpeiffer You can reproduce in runbot 9.0

@JordiBForgeFlow
Copy link
Sponsor Member

Could you cherry-pick the commits from merged #291 to this PR?

@adrienpeiffer
Copy link
Contributor Author

@jbeficent Done !

@JordiBForgeFlow
Copy link
Sponsor Member

@adrienpeiffer can you attend to the few travis errors? Also, curious why runbot is still complaining that the purchase_request module is not existing. It has already been merged. Perhaps the PR needs rebasing?

@adrienpeiffer adrienpeiffer force-pushed the 10-mig-purchase_request_to_rfq-ape branch from ae2f939 to d8ba950 Compare October 28, 2016 06:14
@adrienpeiffer
Copy link
Contributor Author

Rebased

Copy link

@Garamotte Garamotte left a comment

Choose a reason for hiding this comment

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

Some comments about renamed field attributes and unused variables/imports.

The infinite loop that breaks the build on runbot is caused by the digits_compute attribute (the one in this PR, and another in the purchse_request module).

string="Purchase Status",
selection=lambda self:
self.env['purchase.order']._fields['state'].selection,
stored=True,

Choose a reason for hiding this comment

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

store=True

product_id = fields.Many2one('product.product', string='Product')
name = fields.Char(string='Description', required=True)
product_qty = fields.Float(string='Quantity to purchase',
digits_compute=dp.get_precision('Product UoS'))

Choose a reason for hiding this comment

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

digits=dp.get_precision('Product UoS'))

import odoo.addons.decimal_precision as dp
from odoo import _, api, exceptions, fields, models
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT, \
DEFAULT_SERVER_DATETIME_FORMAT

Choose a reason for hiding this comment

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

Unused, please remove the import.

from odoo import _, api, exceptions, fields, models
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT, \
DEFAULT_SERVER_DATETIME_FORMAT
from datetime import datetime

Choose a reason for hiding this comment

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

Unused, please remove the import.


@api.model
def _prepare_purchase_order_line(self, po, item):
po_line_obj = self.env['purchase.order.line']

Choose a reason for hiding this comment

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

Unused, please remove.

@Garamotte
Copy link

I opened a new PR to fix the field attribute error in purchase_request : #295

@sbidoul
Copy link
Member

sbidoul commented Feb 6, 2017

@adrienpeiffer could you fix the small lint errors?

purchase_request_to_rfq/wizard/purchase_request_line_make_purchase_order.py:7:1: F401 'odoo.tools.DEFAULT_SERVER_DATE_FORMAT' imported but unused
purchase_request_to_rfq/wizard/purchase_request_line_make_purchase_order.py:7:1: F401 'odoo.tools.DEFAULT_SERVER_DATETIME_FORMAT' imported but unused
purchase_request_to_rfq/wizard/purchase_request_line_make_purchase_order.py:9:1: F401 'datetime.datetime' imported but unused
purchase_request_to_rfq/wizard/purchase_request_line_make_purchase_order.py:153:9: F841 local variable 'po_line_obj' is assigned to but never used

<field name="date_required" position="after">
<filter name="purchase_state_none"
string="Purchasing not started"
domain="[('purchase_state','=','none')]"
Copy link
Contributor

Choose a reason for hiding this comment

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

I think that the state never is 'none' so better do [('purchase_state', '=', False)]

@adrienpeiffer adrienpeiffer force-pushed the 10-mig-purchase_request_to_rfq-ape branch 5 times, most recently from 217e0ce to 16a8611 Compare February 7, 2017 21:58
@adrienpeiffer
Copy link
Contributor Author

@sbidoul it's done.
@sergio-teruel I just forward your commit on 9.0 to this branch

@sergio-teruel
Copy link
Contributor

Oks. Thanks..

@AaronHForgeFlow
Copy link
Contributor

It seems to me that you have to rebase your branch to make runbot work. The digits_compute error was corrected in the product_qty field of the purchase request line.

@api.depends('purchase_lines')
def _compute_is_editable(self):
super(PurchaseRequestLine, self)._compute_is_editable()
for rec in self.filtered(lambda p: p in self and p.purchase_lines):

Choose a reason for hiding this comment

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

Is it really required when filtering on self to check that the record is in self ?

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Hi @sylvain-garancher Not sure. What would you suggest instead?

Choose a reason for hiding this comment

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

I suggest to replace self.filtered(lambda p: p in self and p.purchase_lines) by self.filtered(lambda p: p.purchase_lines).

The filtered method loops over self, so p should always be part of self, isn't it ?

JordiBForgeFlow and others added 4 commits February 13, 2017 14:44
* [ADD] test that  cancel an existing demo PO and create a new revision

* [ADD] fill_unrevisioned_name post init hook

* [ADD] purchase request modules

* [IMP] Add try me on runbot

* [FIX] Use suspend_security on search on purchase order for users that have no access right on purchases.

* [ADD] addons table in README.md

* [IMP][purchase_partial_invoicing] Add dependencies informations in readme file

* [FIX] Various fixes

* [FIX] fixed travis errors

* FIX: properly propagate _run() method of procurement.order accross the class hierarchy

* [FIX] travis errors

* [FIX] openerp.models: ir.values.create() with unknown fields: object

* [IMP] Added message notifications on change of the status of the purchase request.

* [IMP] purchase_request_to_requisition. We don't allow to set call for bids and purchase request at the same time in the product form.

* [UPD] prefix versions with 8.0

* [FIX] fixed group by error

* [IMP] extend purchase request line search

* [FIX] fixed search filter

* [MOV] move addons out of __unported__ (they remain not installable)

* [TEST][purchase_partial_invoicing] Call ir.rule register hook

* [FIX] do not display product_tmpl_id on product_supplier_info form if opened from product form

* [FIX][product_supplierinfo_discount] Fail when same products has multiple records of same supplier

Odoo does not restrict entering mulltiple product.supplierinfo records
for the same product and same partner.

* [FIX][product_supplierinfo_discount] Less code to select first element

* [UPD] addons table in README.md

* [IMP] split from purchase_request_to_requisition the module purchase_request_procurement

* [FIX] pep8 issues

* FIX

1.create purchase order ..maybe: PO00001
2.confirm purchase order
3. cancle this purchase order .name: PO00001
4.new revision ....then create new purhcase order name i s PO00001-1
5.cancel this purchase order name PO00001-1
6.more->duplicate
7.new purchase order create...name is PO00002
8. confirm this order PO00002
9.cancel this order PO00002
10. new revision.....then error

Order Reference must be unique per Company

* [FIX] fix error when create PO/Bid from PR line w/o product_id

* [FIX] adjustments to make the purchase request compatible with v8

* [FIX] fix related to picking type and warehouse for v8

Minimum fix just to continue on purchase_requistion_operating_unit
Otherwise, it just give me errors.
Please review and make fix to your branch and I will follow.

* [FIX] recover what has fixed from previous PR (was removed)

ForgeFlow#2

* [FIX] purchase_request_to_rfq, assign date_planned if none.

If no product_id, date_planned won't be prepare. But we need it or
error.

* [ENH] purchase_request, PR Line only filtered with non-Draft state

* [IMP] .travis.yml: Coveralls+Transifex activation

* add purchase_picking_state module

* add french translate

* OCA Transbot updated translations from Transifex

* [IMP] purchase_discount: load price with discount in stock_move when confirm a purchase order

* fix README.rst and fix openerp.py and refactor _compute_picking_state method and add tests and add invisible attribut for picking_state field in views

* add icon.png

* fix tests

* [ADD] Module to split purchase receptions by dates

* [MIGR] purchase_delivery_split_date

Use v8 API
Follow the OCA guidelines for manifest and README
PEP8
Extend _create_stock_move because the method we used to extend in v7 doesn't exist anymore.

* [IMP] Unit test for purchase_delivery_split_date

* [FIX] manifest conventions

* Conform to OCA standards

* [UPD] addons table in README.md

* OCA Transbot updated translations from Transifex

* [UPD] addons table in README.md

* [ADD]purchase_rfq_number

* [UPD]Changing url for issue on README.rst

* [FIX]Fix errors in writing

* [UPD]Creating Unittest

* Change Block Comment from '#' into '# '

* [ADD] setup.py

* OCA Transbot updated translations from Transifex

* [FIX] a line with a bigger invoiced quantity than the quantity ordered should be considered as invoiced.

* [FIX] Error raised if no procurement during the creation of the purchase order form the purchase request

* [UPD] addons table in README.md

* [ADD] setup.py

* OCA Transbot updated translations from Transifex

* [ADD] translation files .pot

* OCA Transbot updated translations from Transifex

* [FIX] messages to the purchase request generated in purchase order, stock picking and purchase requisition should notify to followers of the purchase request.

* [ADD] purchase_requisition_type (OCA#231)

* [ADD] purchase_requisition_type

* Delete duplicate usage on README.rst

* Fix error when encode BID

* [UPD] Add invoice_method on _prepare_purchase_order function

* [UPD] Add invoice_method on unittest prepare_purchase_order

* Fixing flake error E501

* [UPD] addons table in README.md

* [ADD] setup.py

* [CHG] greenify travis
* Move yml into python test
* Pep8/Flake8

* [CHG] greenify travis and port ymal tests to python

* OCA Transbot updated translations from Transifex

* [CHG] add dependency on purchase_request_to_rfq
see also ForgeFlow#9 (comment)

* [FIX] travis

* [CHG] restart build

* [REV]test_prepare_purchase_order.py (OCA#235)

* [ADD] purchase request modules

* [IMP] Add try me on runbot

* [FIX] Various fixes

* [FIX] fixed travis errors

* FIX: properly propagate _run() method of procurement.order accross the class hierarchy

* [FIX] travis errors

* [FIX] openerp.models: ir.values.create() with unknown fields: object

* [IMP] Added message notifications on change of the status of the purchase request.

* [IMP] purchase_request_to_requisition. We don't allow to set call for bids and purchase request at the same time in the product form.

* [FIX] fixed group by error

* [IMP] extend purchase request line search

* [FIX] fixed search filter

* [IMP] split from purchase_request_to_requisition the module purchase_request_procurement

* [FIX] pep8 issues

* [FIX] fix error when create PO/Bid from PR line w/o product_id

* [FIX] adjustments to make the purchase request compatible with v8

* [FIX] fix related to picking type and warehouse for v8

Minimum fix just to continue on purchase_requistion_operating_unit
Otherwise, it just give me errors.
Please review and make fix to your branch and I will follow.

* [FIX] recover what has fixed from previous PR (was removed)

ForgeFlow#2

* [ENH] purchase_request, PR Line only filtered with non-Draft state

* [FIX] Error raised if no procurement during the creation of the purchase order form the purchase request

* [ADD] translation files .pot

* [FIX] messages to the purchase request generated in purchase order, stock picking and purchase requisition should notify to followers of the purchase request.

* [CHG] greenify travis
* Move yml into python test
* Pep8/Flake8

* [CHG] greenify travis and port ymal tests to python

* [CHG] add dependency on purchase_request_to_rfq
see also ForgeFlow#9 (comment)

* [FIX] travis

* [CHG] restart build

* [FIX] pull189#issuecomment-225476547

* [FIX] pull189 flake8 issues

* [FIX] pull189 flake8 issues

* [FIX] pull189 discussion_r68006610

* [FIX] pull189 discussion_r68008046
…e.order and purchase.order.line * purchase.requisition and purchase.requisition.line
…_lines due to wrong implementation with api.multi (OCA#241)
@sbidoul sbidoul force-pushed the 10-mig-purchase_request_to_rfq-ape branch from 16a8611 to c6ca7bf Compare February 13, 2017 13:45
@sbidoul
Copy link
Member

sbidoul commented Feb 13, 2017

rebased. travis and runbot are green

# Leave the purchase order order to calculate its prices
# itself
po_line._onchange_quantity()
po_line.purchase_request_lines = [(4, line.id)]
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

This line should be executed regardless if new_qty > po_line.product_qty. \

When you create two PR lines for 1 unit for imac, which has a minimum qty of 5, now the PO line is only linked to PR 1, not to PR2. That is incorrect.

This issue also occurs in 9.0 and 8.0

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

Created a separate issue #333

@LoisRForgeFlow
Copy link
Contributor

LoisRForgeFlow commented Feb 24, 2017

This looks good! I agree with the changes proposed by @jbeficent and @sylvain-garancher though and also I propose to add this commit 93d284b to be able to add some description in the wizard and keep it in the created PO.

@LoisRForgeFlow
Copy link
Contributor

Hello @adrienpeiffer , can you also add the fix made here: #371 for v9?

@aduijs
Copy link

aduijs commented May 13, 2017

Whats the status on this migration?

@JordiBForgeFlow
Copy link
Sponsor Member

We will merge this now. Review comments correspond to requests for new features, and I propose to crate separate PR's.

@JordiBForgeFlow JordiBForgeFlow merged commit 392808d into OCA:10.0 May 15, 2017
@JordiBForgeFlow
Copy link
Sponsor Member

Thanks @adrienpeiffer! This is now merged.

@sbidoul sbidoul deleted the 10-mig-purchase_request_to_rfq-ape branch May 15, 2017 09:19
LoisRForgeFlow added a commit to ForgeFlow/purchase-workflow that referenced this pull request May 15, 2017
rgarnau pushed a commit to ForgeFlow/purchase-workflow that referenced this pull request Aug 31, 2017
HviorForgeFlow pushed a commit to ForgeFlow/purchase-workflow that referenced this pull request Apr 23, 2018
tschanzt pushed a commit to camptocamp/purchase-workflow that referenced this pull request May 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants