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

[FIX] point_of_sale: default global discount #36665

Conversation

@rhe-odoo
Copy link

commented Sep 11, 2019

Change the default value of the miscellaneous product to a discount product. When the module pos_discount is installed, the default value will now be the discount product.

I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

@robodoo robodoo added the seen 🙂 label Sep 11, 2019

@C3POdoo C3POdoo added the RD label Sep 11, 2019

@@ -7,19 +7,11 @@
class PosConfig(models.Model):
_inherit = 'pos.config'

def _default_discount_product_id(self):
return self.env.ref("point_of_sale.product_product_consumable")

This comment has been minimized.

Copy link
@pimodoo

pimodoo Sep 11, 2019

Contributor

it will traceback if the "product_product_consumable" you should probably do something like return self.env.ref('point_of_sale.product_product_consumable', raise_if_not_found=False) to return Flase if the product is does not exist.

@rhe-odoo rhe-odoo force-pushed the odoo-dev:saas-12.5-pos-rename-miscellaneous-product-rhe branch from d0d0742 to 6a2ed58 Sep 11, 2019

@pimodoo

This comment has been minimized.

Copy link
Contributor

commented Sep 11, 2019

you should also check that the company = company of the config or company_id is false on the product. more or less like in '_default_sale_journal' of pos config.

Why did you changed the behavior to use default instead of onchange? It means that the product is set even if your checkbox is not set, and percentage of discount is not changed eihter, and your branch is red because of that.

Also you are removing the reference to the image: 'product_product_49-image.jpg' It does not seems to be used anymore, probably you can remove the image too.

@rhe-odoo rhe-odoo force-pushed the odoo-dev:saas-12.5-pos-rename-miscellaneous-product-rhe branch from 9d577d5 to 7617202 Sep 12, 2019

@robodoo robodoo added the CI 🤖 label Sep 12, 2019

@@ -7,19 +7,14 @@
class PosConfig(models.Model):
_inherit = 'pos.config'

def _default_discount_product_id(self):
product = self.env.ref("point_of_sale.product_product_consumable", raise_if_not_found=False)
if not product or product.company_id and product.company_id != self.company_id:

This comment has been minimized.

Copy link
@pimodoo

pimodoo Sep 13, 2019

Contributor

le self.company_id ne marche pas dans un default, car l'object n'est pas encore là et tu ne peux pas l'utiliser, il faut en réalité faire un onchange sur company_id, tu peux regarder ce qui a été fait ici, c'est +- la même chose: e451305

@rhe-odoo rhe-odoo force-pushed the odoo-dev:saas-12.5-pos-rename-miscellaneous-product-rhe branch from 7617202 to f3c357a Sep 13, 2019

@robodoo robodoo removed the CI 🤖 label Sep 13, 2019

@api.model
def _default_discount_value_on_module_install(self):
pos = self.env['pos.config'].search([('module_pos_discount', '=', 'True')], limit=1)
product = self.env.ref("point_of_sale.product_product_consumable", raise_if_not_found=False)

This comment has been minimized.

Copy link
@pimodoo

pimodoo Sep 13, 2019

Contributor

you can probably just do:
configs = self.env['pos.config'].search([])
for conf in configs:
conf._default_discount_product_id()

@robodoo robodoo added the CI 🤖 label Sep 13, 2019

[FIX] point_of_sale: default global discount
Change the default value of the miscellaneous product to a discount product. When the module pos_discount is installed, the default value will now be the discount product.

task: bug fix

@rhe-odoo rhe-odoo force-pushed the odoo-dev:saas-12.5-pos-rename-miscellaneous-product-rhe branch from f3c357a to 0c067f5 Sep 13, 2019

@robodoo robodoo added CI 🤖 and removed CI 🤖 labels Sep 13, 2019

@pimodoo

This comment has been minimized.

Copy link
Contributor

commented Sep 20, 2019

robodoo r+ rebase-ff

@robodoo robodoo added the r+ 👌 label Sep 20, 2019

@robodoo

This comment has been minimized.

Copy link
Contributor

commented Sep 20, 2019

Merge method set to rebase and fast-forward

robodoo pushed a commit that referenced this pull request Sep 20, 2019
[FIX] point_of_sale: default global discount
Change the default value of the miscellaneous product to a discount product. When the module pos_discount is installed, the default value will now be the discount product.

closes #36665

Task: bug fix
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
robodoo pushed a commit that referenced this pull request Sep 20, 2019
[FIX] point_of_sale: default global discount
Change the default value of the miscellaneous product to a discount product. When the module pos_discount is installed, the default value will now be the discount product.

closes #36665

Task: bug fix
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>

@robodoo robodoo added merged 🎉 and removed merging 👷 labels Sep 20, 2019

@robodoo

This comment has been minimized.

Copy link
Contributor

commented Sep 20, 2019

Merged at 1a3dcfe, thanks!

@robodoo robodoo closed this Sep 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.