Add model, record and records attribute on Wizard
issue9421 review309861012
This commit is contained in:
1 parent
671e1b2599
commit
1cf17ecf7e
2 files changed
+18
-41
No files matched your search
+4
-6
@@ -518,21 +518,19 @@ class Count(Wizard):
|
||||
|
||||
def default_quantity(self, fields):
|
||||
pool = Pool()
|
||||
Inventory = pool.get('stock.inventory')
|
||||
InventoryLine = pool.get('stock.inventory.line')
|
||||
Warning = pool.get('res.user.warning')
|
||||
context = Transaction().context
|
||||
inventory = Inventory(context['active_id'])
|
||||
values = {}
|
||||
lines = InventoryLine.search(self.get_line_domain(inventory), limit=1)
|
||||
lines = InventoryLine.search(
|
||||
self.get_line_domain(self.record), limit=1)
|
||||
if not lines:
|
||||
warning_name = '%s.%s.count_create' % (
|
||||
inventory, self.search.search)
|
||||
self.record, self.search.search)
|
||||
if Warning.check(warning_name):
|
||||
raise InventoryCountWarning(warning_name,
|
||||
gettext('stock.msg_inventory_count_create_line',
|
||||
search=self.search.search.rec_name))
|
||||
line, = InventoryLine.create([self.get_line_values(inventory)])
|
||||
line, = InventoryLine.create([self.get_line_values(self.record)])
|
||||
else:
|
||||
line, = lines
|
||||
values['line'] = line.id
|
||||
|
||||
+14
-35
@@ -600,15 +600,9 @@ class OpenProductQuantitiesByWarehouse(Wizard):
|
||||
open_ = StateAction('stock.act_product_quantities_warehouse_move')
|
||||
|
||||
def do_open_(self, action):
|
||||
pool = Pool()
|
||||
ProductQuantitiesByWarehouse = pool.get(
|
||||
'stock.product_quantities_warehouse')
|
||||
context = Transaction().context
|
||||
|
||||
record = ProductQuantitiesByWarehouse(context['active_id'])
|
||||
domain = [('date', '>=', record.date)]
|
||||
domain = [('date', '>=', self.record.date)]
|
||||
action['pyson_search_value'] = PYSONEncoder().encode(domain)
|
||||
action['name'] += ' (' + record.rec_name + ')'
|
||||
action['name'] += ' (' + self.record.rec_name + ')'
|
||||
return action, {}
|
||||
|
||||
|
||||
@@ -799,14 +793,14 @@ class RecomputeCostPrice(Wizard):
|
||||
pool = Pool()
|
||||
Move = pool.get('stock.move')
|
||||
Product = pool.get('product.product')
|
||||
Template = pool.get('product.template')
|
||||
context = Transaction().context
|
||||
|
||||
if context['active_model'] == 'product.product':
|
||||
products = Product.browse(context['active_ids'])
|
||||
elif context['active_model'] == 'product.template':
|
||||
templates = Template.browse(context['active_ids'])
|
||||
if self.model.__name__ == 'product.product':
|
||||
products = self.records
|
||||
elif self.model.__name__ == 'product.template':
|
||||
templates = self.records
|
||||
products = sum((t.products for t in templates), ())
|
||||
else:
|
||||
products = []
|
||||
|
||||
from_ = None
|
||||
for sub_products in grouped_slice(products):
|
||||
@@ -823,18 +817,7 @@ class RecomputeCostPrice(Wizard):
|
||||
return {'from_': from_}
|
||||
|
||||
def transition_recompute(self):
|
||||
pool = Pool()
|
||||
Product = pool.get('product.product')
|
||||
Template = pool.get('product.template')
|
||||
|
||||
context = Transaction().context
|
||||
|
||||
if context['active_model'] == 'product.product':
|
||||
products = Product.browse(context['active_ids'])
|
||||
Product.recompute_cost_price(products, start=self.start.from_)
|
||||
elif context['active_model'] == 'product.template':
|
||||
templates = Template.browse(context['active_ids'])
|
||||
Template.recompute_cost_price(templates, start=self.start.from_)
|
||||
self.model.recompute_cost_price(self.records, start=self.start.from_)
|
||||
return 'end'
|
||||
|
||||
|
||||
@@ -858,16 +841,13 @@ class ModifyCostPrice(Wizard):
|
||||
def transition_modify(self):
|
||||
pool = Pool()
|
||||
Product = pool.get('product.product')
|
||||
Template = pool.get('product.template')
|
||||
Revision = pool.get('product.cost_price.revision')
|
||||
Date = pool.get('ir.date')
|
||||
context = Transaction().context
|
||||
today = Date.today()
|
||||
revisions = []
|
||||
costs = defaultdict(list)
|
||||
if context['active_model'] == 'product.product':
|
||||
recompute_cost_price = Product.recompute_cost_price
|
||||
products = records = Product.browse(context['active_ids'])
|
||||
if self.model.__name__ == 'product.product':
|
||||
products = records = list(self.records)
|
||||
for product in products:
|
||||
revision = self.get_revision(Revision)
|
||||
revision.product = product
|
||||
@@ -880,9 +860,8 @@ class ModifyCostPrice(Wizard):
|
||||
cost = revision.get_cost_price(product.cost_price)
|
||||
costs[cost].append(product)
|
||||
records.remove(product)
|
||||
elif context['active_model'] == 'product.template':
|
||||
recompute_cost_price = Template.recompute_cost_price
|
||||
templates = records = Template.browse(context['active_ids'])
|
||||
elif self.model.__name__ == 'product.template':
|
||||
templates = records = list(self.records)
|
||||
for template in templates:
|
||||
revision = self.get_revision(Revision)
|
||||
revision.template = template
|
||||
@@ -900,7 +879,7 @@ class ModifyCostPrice(Wizard):
|
||||
Product.update_cost_price(costs)
|
||||
if records:
|
||||
start = min((r.date for r in revisions), default=None)
|
||||
recompute_cost_price(records, start=start)
|
||||
self.model.recompute_cost_price(records, start=start)
|
||||
return 'end'
|
||||
|
||||
def get_revision(self, Revision):
|
||||
|
||||
Reference in new issue
Block a user