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

[IMP] No negative by default #258

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions stock_no_negative/models/product_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,20 @@
#
##############################################################################
from openerp import fields, models
from openerp.tools import config


class ProductTemplate(models.Model):
_inherit = 'product.template'

# for not to break other tests
def _get_default_no_negative_policy(self):
return not (config['test_enable'] and
not self.env.context.get('check_no_negative'))

check_no_negative = fields.Boolean(
'Check no negative',
default=_get_default_no_negative_policy,
Copy link

Choose a reason for hiding this comment

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

Use lambda to allow inheritance lambda s: s._get_default_no_negative_policy()

Copy link

Choose a reason for hiding this comment

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

Although I agree with @pedrobaeza comment which would remove this entirely

help='If this field is True can not move this'
' product in negative quantity available in'
' the internal location source')