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

[16.0][MIG] stock_picking_invoicing: Migration to 16.0 #1465

Merged
merged 134 commits into from
Nov 28, 2023

Conversation

mbcosta
Copy link
Contributor

@mbcosta mbcosta commented May 25, 2023

Standard migration of stock_picking_invoicing to v16, #1250 some changes was necessary:

  • To avoid error in the Views with the Group parameter, I'm just create a simply method to check if the user has the group Account and make field Readonly if not, log of the error:

Field 'invoice_state' used in attrs ({'invisible': [('invoice_state', 'in', [False, 'none'])]}) is restricted to the group(s) account.group_account_invoice.

This PR should be replace #1449 because it's based in the v15 and by the tests I'm made with demo data the module are working as expect.

cc @renatonlima @rvalyi @jguenat

@jguenat
Copy link
Member

jguenat commented May 25, 2023

Thanks @mbcosta you beat me to it I was planning to work on this next week :)
I'll review this more thoroughly Tuesday but here is my first comment:

"To avoid error in the Views with the Group parameter, I'm just create a simply method to check if the user has the group Account"

I think this is a little bit overkill and it seems that the standard "odoo way" of doing it is to simply add the field a second time with invisible="1". It mentioned in the comments of this PR odoo/odoo#95729

Copy link
Member

@jguenat jguenat left a comment

Choose a reason for hiding this comment

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

LG thanks

Comment on lines 14 to 39
def _get_taxes(self, fiscal_position, inv_type):
"""
Map product taxes based on given fiscal position
:param fiscal_position: account.fiscal.position recordset
:param inv_type: string
:return: account.tax recordset
"""
product = self.mapped("product_id")
product.ensure_one()
if inv_type in ("out_invoice", "out_refund"):
taxes = product.taxes_id
else:
taxes = product.supplier_taxes_id
company_id = self.env.context.get("force_company", self.env.company.id)
my_taxes = taxes.filtered(lambda r: r.company_id.id == company_id)
return fiscal_position.map_tax(my_taxes)

@api.model
def _get_account(self, fiscal_position, account):
"""
Map the given account with given fiscal position
:param fiscal_position: account.fiscal.position recordset
:param account: account.account recordset
:return: account.account recordset
"""
return fiscal_position.map_account(account)
Copy link
Member

Choose a reason for hiding this comment

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

Seems it's not used anymore

@mbcosta mbcosta force-pushed the 16.0-mig-stock_picking_invoicing branch from 9675abd to 01d3142 Compare September 8, 2023 21:07
@mbcosta
Copy link
Contributor Author

mbcosta commented Sep 8, 2023

About the last changes:

  • It's seems unnecessary inherit account.move.line objetc and _compute_price_unit method as I did before, tests are checking the cases of Price Unit informed by User in Picking or get Price from Sellers or from PriceList, the commit was removed

  • Despite there are methods to change Invoice State for Invoiced or Not Billable the buttons at some point in the other versions was removed, I didn't noticed before, so I put it back

image

And include onchage method to update the Invoice State when the field in the Picking are changed

image

-Refactoring Tests by create methods to avoid duplicate code and, as said before, included tests for Price Unit cases.

@mbcosta mbcosta force-pushed the 16.0-mig-stock_picking_invoicing branch 2 times, most recently from 389903b to 76f259b Compare September 14, 2023 19:52
@mbcosta
Copy link
Contributor Author

mbcosta commented Sep 14, 2023

We should avaliate the necessity of the Buttons "Set Invoiced" and "Set Not Billable" in Picking View. In my opinion the case of Not Billable is valide to allow users "fix" when a Picking was wrong marked "To Be Invoiced", I'm not certain about the case of "Invoiced", in which cases it will be use.

odooNextev pushed a commit to odooNextev/account-invoicing that referenced this pull request Sep 29, 2023
Copy link
Member

@hildickethan hildickethan left a comment

Choose a reason for hiding this comment

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

code+functional review, but I think it's more standard procedure to squash most of these migration commits unless they are adding new features
a86ecf5, e713989, 5ed7932, 473c119, b0d65e7, 273d4cb, 76f387f and 76f259b could all be squashed as generic migration
6af8bb2 and 573b5a2 i think are fine as is seperately as new features

:param invoice: account.move
:return: dict
"""
name = ", ".join(moves.mapped("name"))

Choose a reason for hiding this comment

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

hi, @mbcosta we found a problem when invoicing a picking with multiple moves with the same product it duplicates the name of the product in the invoice line and if we have the group = "partner_product" . We think that if changing this line to only get the first move's description if using the partner_prooduct option should avoid the issue.

mbcosta and others added 9 commits November 28, 2023 15:43
…group(s)' when field has parameter Groups and are used in for defined an attribute/attrs in the Views and included the dependency of base_view_inheritance_extension module.
…voice consider the value of Product Pricelist or the Seller Price, changed Demo Data for tests.
…al=Hide), to allow users view or, if necessary, change the value.
…o the users be able setting Invoice State to Invoiced or Not Billable, also included onchange method to update this field in Move Lines when changed in Picking.
…d error of Tracking by Lot when MRP module are installed, but use a Product with BoM and Route Buy.
…licate code and included tests for the cases when Price Unit are Informed by User, Sellers and Pricelist.
…Line when Grouping Pickings by Partner/Product.
@mbcosta mbcosta force-pushed the 16.0-mig-stock_picking_invoicing branch from 76f259b to 95d4cd3 Compare November 28, 2023 19:04
@mbcosta
Copy link
Contributor Author

mbcosta commented Nov 28, 2023

Thanks @hildickethan-S73 @adrip-s73 for your review, about the problems:

  • Squash 4 commits

image

commit 8c69b40 has a different author

  • Duplicate field Name/Label in Invoice Line in the case of Grouped Pickings by Partner/Product,

image

In the last commit I tried to fix it, I let separated commit to allow a backport, if necessary, or to made some change after reviews.

image

Copy link
Member

@rvalyi rvalyi left a comment

Choose a reason for hiding this comment

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

kudos for the hard work @mbcosta! ok for me, I think we can merge now as @jguenat approved and as you fixed the issue spotted 2 weeks ago.

@rvalyi
Copy link
Member

rvalyi commented Nov 28, 2023

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

This PR looks fantastic, let's merge it!
Prepared branch 16.0-ocabot-merge-pr-1465-by-rvalyi-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit aec3911 into OCA:16.0 Nov 28, 2023
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at 47cd67c. Thanks a lot for contributing to OCA. ❤️

@mbcosta
Copy link
Contributor Author

mbcosta commented Nov 28, 2023

thank all for review, if you find some problem or has a doubt about this module please mark me in the issue or PR, I have worked in this module for a while because it's important for Brazilian Localization so we need to keep it functional, but we also work to keep compatible with another countries.

@jguenat
Copy link
Member

jguenat commented Nov 29, 2023

thank you @mbcosta for your work !

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.