Skip to content

Commit 1efe80e

Browse files
committed
[IMP] connector_magento: Add export_magento_qty button to force recompute qty in products
1 parent 97ef11c commit 1efe80e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

connector_magento/models/product/common.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,14 @@ def _recompute_magento_qty_backend(self, backend, products, read_fields=None):
161161
records = self_with_location.browse(chunk_ids)
162162
for product in records.read(fields=product_fields):
163163
new_qty = self._magento_qty(product, backend, location, stock_field)
164-
if new_qty != product["magento_qty"]:
164+
if new_qty != product["magento_qty"] or self.env.context.get(
165+
"force_recompute"
166+
):
165167
self.browse(product["id"]).magento_qty = new_qty
166168

169+
def export_magento_qty(self):
170+
return self.with_context(force_recompute=True).recompute_magento_qty()
171+
167172
def _magento_qty(self, product, backend, location, stock_field):
168173
""" Return the current quantity for one product.
169174

connector_magento/views/product_views.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,12 @@
5353
class="oe_link oe_inline"
5454
type="object"
5555
/>
56+
<button
57+
name="export_magento_qty"
58+
string="(export)"
59+
class="oe_link oe_inline"
60+
type="object"
61+
/>
5662
</div>
5763
</group>
5864
</form>

0 commit comments

Comments
 (0)