-
Notifications
You must be signed in to change notification settings - Fork 116
[REF] pos_loyalty, pos*: real time syncing adaptation for loyalty #4684
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
base: master-pos_ref_syncing_team-branch
Are you sure you want to change the base?
[REF] pos_loyalty, pos*: real time syncing adaptation for loyalty #4684
Conversation
This PR targets the un-managed branch odoo-dev/odoo:master-pos_ref_syncing_team-branch, it needs to be retargeted before it can be merged. |
c1ab495
to
e4137ed
Compare
e37abd3
to
2ce244a
Compare
9896110
to
bafc7eb
Compare
be34796
to
3c3236c
Compare
52727f9
to
14e5701
Compare
This PR targets the un-managed branch odoo-dev/odoo:master-pos_ref_syncing_team-branch, it needs to be retargeted before it can be merged. |
14e5701
to
75e684d
Compare
75e684d
to
fd1c2a7
Compare
@@ -129,7 +129,7 @@ def test_selling_multislot_event_in_pos(self): | |||
self.main_pos_config.with_user(self.pos_user).open_ui() | |||
self.start_pos_tour('SellingMultiSlotEventInPos') | |||
|
|||
order = self.env['pos.order'].search([], order='id desc', limit=1) | |||
order = self.env['pos.order'].search([])[1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this because now there is an extra draft order at the end ? If so, can you add a comment about that ?
@@ -2,7 +2,7 @@ | |||
|
|||
|
|||
{ | |||
'name': 'POS - Restaurant Loyality', | |||
'name': 'POS - Restaurant Loyalty', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you put this in a new commit ? Same for pos_sale_loyalty
"PosLoyaltyTour12", | ||
login="pos_user", | ||
) | ||
self.start_pos_tour("PosLoyaltyTour12") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you put the changes to start_tour
in a separate commit? This way we have one for renaming the methods and one for start_tour
|
||
id_updates = {} | ||
|
||
for [operation, *data] in queue: | ||
match operation: | ||
case "CREATE": | ||
model, vals = data | ||
new_record = self.env[model].create([replace_uuid_with_id(model, vals)]) | ||
new_record = self.env[model].sudo().create([replace_uuid_with_id(model, vals)]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we definitely cannot do this.
We cannot have a public method that allows anyone to create any record.
For the specific cases where we need to create records and need higher privileges you can create special methods that you can call from pos. In these methods you have to properly verify that sudo
is used correctly
@@ -247,15 +247,15 @@ def adapt_value(model, key, value): | |||
return [(6, 0, [get_record(self.env[model]._fields[key].comodel_name, val).id for val in value])] | |||
case _: | |||
return value | |||
return {key: adapt_value(model, key, value) for key, value in vals.items()} | |||
return {key: adapt_value(model, key, value) for key, value in vals.items() if self.env[model]._fields.get(key)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you need this ?
Why would you have here keys that don't exist? Ideally the pos should only send valid data via flush
. Perhaps we can do this filtering in the frontend.
The idea is that if you send data that you will just ignore, you can be more resource efficient by not sending the data in the first place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In loyalty, extra fields are created from the front end, like _reward_product_id
and _code_activated_coupon_ids
, which are not available in the backend. In that case, we have to remove those fields from creation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that makes sense. Can you remove the extra fields in js
tough ?
if (this.currentOrder.waitForPushOrder()) { | ||
await this.postPushOrderResolve([this.currentOrder.id]); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we still need this postPush
mechanism ?
Whenever you use data.call
you will force a flush anyways ?
Maybe this can be done in a later task though
@@ -280,7 +280,7 @@ export class PosData extends Reactive { | |||
if (!ids.length) { | |||
return; | |||
} | |||
const vals = models[modelName].getBy("uuid", ids[0]).raw; | |||
const vals = models[modelName].getBy("uuid", ids[0])?.raw || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are the cases where .raw
returns undefined ?
if (this.queue.length > 0) { | ||
throw new Error("There are unsynced changes in the queue."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you replace the error with a console.error
?
@@ -50,6 +50,7 @@ export class DataServiceOptions { | |||
"pos.pack.operation.lot": ["uuid"], | |||
"event.registration": ["uuid"], | |||
"event.registration.answer": ["uuid"], | |||
"loyalty.card": ["uuid", "id"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally we would have added this in an override in loyalty but as it has been the pattern to just add in pos we can also do it here.
On a different note, isn't the id
index created by default? Do you need to manually add it ?
3c3236c
to
1952c76
Compare
In this commit: - We are adding real-time synchronisation for loyalty for real-time loyalty card creation. Created loyalty cards from pos will be updated on order validation with the `confirm_coupon_programs` method call. We will update the loyalty cards' original ID with UUID in order's couponChangePoints uiState Before the method call, so that it will be easy to maintain loyalty cards in pos. task-4766756
In this commit: - We are replacing start_tour with strat_pos_tour, task-4766756
In this commit: - We are renaming methods `_get_reward_lines` with `_getRewardLines` and `_get_regular_order_lines` with `_getRegularOrderLines`. task-4766756
In this commit: - We are replacing `loyality` with `loyalty` in pos_restaurant_loyalty module name. task-4766756
fd1c2a7
to
ae28f15
Compare
In this commit: - We are replacing `loyality` with `loyalty` in pos_sale_loyalty module name. task-4766756
In this commit: - We are fixing test cases for pos_event. task-4766756
ae28f15
to
8770973
Compare
@@ -0,0 +1,181 @@ | |||
# Query: start_pos_tour |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
@@ -144,7 +144,7 @@ def test_pos_loyalty_tour_basic(self): | |||
(4, self.env.ref('stock.group_stock_user').id), | |||
] | |||
}) | |||
self.start_pos_tour("PosLoyaltyTour1") | |||
self.start_pos_tour("PosLoyaltyTour1", login="pos_admin") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you have to use admin
now ?
pos*: point_of_sale, pos_event, pos_restaurant_loaylty, pos_sale_loyalty
In this commit:
confirm_coupon_programs
method call. We will update the loyalty cards' original ID with UUID in order's couponChangePoints uiState before the method call, so that it will be easy to maintain loyalty cards in pos.start_tour
withstart_pos_tour
in test cases.test_physical_gift_card_return_from_floor
to test the physical gift card in the restaurant.loyality
withloyalty
in pos_restaurant_loyalty and pos_sale_loyalty modules.pos_event
module.task-4766756