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] eater #521

Merged
merged 35 commits into from
Oct 24, 2023
Merged

[16.0] [MIG] eater #521

merged 35 commits into from
Oct 24, 2023

Conversation

victor-champonnois
Copy link
Member

@victor-champonnois victor-champonnois commented Aug 3, 2023

internal task : https://gestion.coopiteasy.be/web#id=10884&action=475&active_id=492&model=project.task&view_type=form&menu_id=

I need technical input on two questions : bca5176 and 9902d88

@polchampion Since the field "customer" has been removed in v13, I removed

  • the restriction on customer in the domain for adding new eaters.
  • The invisibility of the field for non-customer contact : so the field Eater/worker is now visible on all contacts

This is not ideal, but I don't see a better solution. We could use the customer_rank field, which starts at zero and increases with the contact's orders. But this would mean that new contacts or contact that never shopped could not been added as Eater.
Maybe we could make the field invisible for companies ?

@polchampion
Copy link
Collaborator

@victor-champonnois I think it's fine as you did, let's keep it simple. Can you ping me when it's live in test?

@cathLemb
Copy link

"Maybe we could make the field invisible for companies ?"
Not possible as bees for example uses eater field on companies.

@carmenbianca
Copy link
Collaborator

I just realised that #516 is not is not included in this PR, and that the changes to customer will conflict with some changes. I'll fix up #516 and then rebase this work on top of that later down the line.

Copy link
Collaborator

@carmenbianca carmenbianca left a comment

Choose a reason for hiding this comment

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

some notes

Copy link
Collaborator

Choose a reason for hiding this comment

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

This font (and some other static resources) are deleted in the 13.0 migration commit. Why?

Copy link
Member Author

Choose a reason for hiding this comment

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

I could have removed it in a separate commit. It's just that it's not used and it makes no sense to keep this file here.

attrs="{'invisible': ['|', ('customer', '=', False), ('eater', 'not in', ('worker_eater'))]}"
attrs="{'invisible': [('eater', 'not in', ('worker_eater'))]}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be in the 13.0 migration commit.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Comment on lines 40 to 44
<field name="eater" attrs="{'invisible': [('customer', '=', False)]}" />
<field name="eater" />
Copy link
Collaborator

Choose a reason for hiding this comment

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

idem

Copy link
Member Author

Choose a reason for hiding this comment

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

done

and partner.parent_eater_id.id != values.get("parent_eater_id")
and partner.parent_eater_id != values.get("parent_eater_id")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This makes no sense to me.

Comment on lines 25 to 26
# fixme: shouldn't the check on "values.get("parent_eater_id")" be before
# the for loop to avoid looping through all the contacts at every write?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Comment on lines 40 to 46
# replace many2many command when writing on child_eater_ids to just
# remove the link
# fixme : is this still necessary ? In a many2many widget, removing an item
# is a "3" (unlink) command. In which case would this be a delete command ?
# replace many2many command when writing on child_eater_ids to unlink
# rather than delete
if "child_eater_ids" in values:
for command in values["child_eater_ids"]:
if command[0] == 2:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess it depends on why this exists. The apparent goal to me is 'don't accidentally delete the linked child eaters when severing the link'. But why would the '2' command ever be sent when the '3' command is intended?

For context:

  • (2, id, _) removes the link to and deletes the id related record.
  • (3, id, _) removes the link to, but does not delete, the id related record.
    This is usually what you will use to delete related records on many-to-many
    fields.

In any case, if we keep this line, a test should be added.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would be in favor of removing it then. I don't see why this would be needed for this specific many2many field. Do you agree ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not a Many2many field. Not sure why the comment calls it a 'many2many command'.

I'm happy to drop this code also. Let's just make a note of it somewhere that the functional tester can be aware of this.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

Copy link
Member Author

Choose a reason for hiding this comment

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

(note in the task)

@robinkeunen
Copy link
Member

The migration commits should be stashed together.

@huguesdk
Copy link
Member

huguesdk commented Oct 9, 2023

isn’t the module name too generic for such a specific module?

victor-champonnois and others added 15 commits October 9, 2023 10:53
[UPD] Update member_card.pot

Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
[UPD] Update eater.pot

Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
[UPD] Update eater_member_card.pot

Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
[REF] put splitted modules as dependencies

[FIX] test-requirements

[FIX] remove beesdoo_base demo data in manifest

Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
[FIX] contributors

[FIX] remove deprecated demo data

Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
We do not need to rename view names when moved from one
module to the other. Odoo cleans up by himself as long
as they are not defined as noupdate.

Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
into:
- product_main_supplier
- sale_suggested_price
- sale_adapt_price_wizard

[REF] split beesdoo_product -> product_main_supplier

[FIX] sale_suggested_price dep on product_main_supplier

[ADD] module sale_edit_price_wizard

[REF] rename sale_edit_price_wizard ->  sale_adapt_price_wizard

[REF] move rounding_method to sale_suggested_price

[REF] refactor following PR 320

[REF] search product_code -> product_main_seller

[FIX] bug adapt_sales_price

[IMP] use float_compare to compare prices

[REF] move list_price_write_date to sale_adapt_price_wizard

[FIX] beesdoo_product: main_seller_id search

[FIX] run precommit

fix

Signed-off-by: Carmen Bianca BAKKER <carmen@coopiteasy.be>
Copy link
Collaborator

@carmenbianca carmenbianca left a comment

Choose a reason for hiding this comment

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

I rebased this on top of the latest 12.0 to also include #516. I also applied a fix at the end, but I'm not entirely sure why the code that I fixed exists.

I'd like a confirmation that the tagged code is useful before we merge this.

Comment on lines 52 to 69
if values.get("parent_eater_id"):
for partner in self:
if (
partner.parent_eater_id
and partner.parent_eater_id.id != values.get("parent_eater_id")
):
raise ValidationError(
_(
"You are trying to assign %(eater)s as an eater to"
" a new partner, but this eater is already"
" assigned to %(old_partner)s. Please remove the link"
" before creating a new one."
)
% {
"eater": partner.name,
"old_partner": partner.parent_eater_id.name,
}
)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the use case here?

Copy link
Member

Choose a reason for hiding this comment

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

You can't be the eater of two workers.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But this would change the parent eater ("worker"), no? So after the operation, you still only have one parent.

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, that's weird.

Copy link
Member

@robinkeunen robinkeunen Oct 24, 2023

Choose a reason for hiding this comment

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

It dates back from 8 years ago. Let's trust ourselves and state that this is useless. 3f4d9f6

@codecov-commenter
Copy link

Codecov Report

Merging #521 (3d7f339) into 16.0 (4803b52) will increase coverage by 1.31%.
The diff coverage is 93.75%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##             16.0     #521      +/-   ##
==========================================
+ Coverage   66.26%   67.58%   +1.31%     
==========================================
  Files          45       53       +8     
  Lines        1592     1672      +80     
  Branches      217      230      +13     
==========================================
+ Hits         1055     1130      +75     
- Misses        495      500       +5     
  Partials       42       42              
Files Coverage Δ
eater/__init__.py 100.00% <100.00%> (ø)
eater/models/__init__.py 100.00% <100.00%> (ø)
eater/tests/__init__.py 100.00% <100.00%> (ø)
eater/tests/test_eater.py 100.00% <100.00%> (ø)
eater/tests/test_partner.py 100.00% <100.00%> (ø)
eater/wizard/__init__.py 100.00% <100.00%> (ø)
eater/models/partner.py 92.00% <92.00%> (ø)
eater/wizard/new_eater_wizard.py 76.92% <76.92%> (ø)

@@ -6,15 +6,15 @@ class TestEater(TransactionCase):
def test_assign_parent_eater(self):
self.assertTrue(
self.env.ref("eater.eater2").write(
{"parent_eater_id": self.env.ref("eater.eater1")}
{"parent_eater_id": self.env.ref("eater.worker1").id}
Copy link
Member

Choose a reason for hiding this comment

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

it's better practice to create records in the tests and leave demo data for demo.

Comment on lines 39 to 29
<record id="worker1" model="res.partner">
<field name="name">Gijs Eaterdam</field>
<field name="firstname">Gijs</field>
<field name="lastname">Eaterdam</field>
<field name="eater">worker_eater</field>
<field name="is_company" eval="False" />
</record>
Copy link
Member

Choose a reason for hiding this comment

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

It's better to overload existing partners than creating new ones.

@carmenbianca carmenbianca self-requested a review October 24, 2023 13:51
Copy link
Collaborator

@carmenbianca carmenbianca left a comment

Choose a reason for hiding this comment

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

@robinkeunen
Copy link
Member

/ocabot merge nobump

@github-grap-bot
Copy link
Contributor

What a great day to merge this nice PR. Let's do it!
Prepared branch 16.0-ocabot-merge-pr-521-by-robinkeunen-bump-nobump, awaiting test results.

@github-grap-bot github-grap-bot merged commit 80eadce into 16.0 Oct 24, 2023
2 checks passed
@github-grap-bot
Copy link
Contributor

Congratulations, your PR was merged at 48ba329. Thanks a lot for contributing to beescoop. ❤️

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.

8 participants