[Fix] Is fixed asset checkbox not checked if user duplicate the existing invoice

This commit is contained in:
Rohit Waghchaure 2018-12-19 15:06:44 +05:30
parent 402ffa8b29
commit f6f503a1f6
2 changed files with 14 additions and 1 deletions

View File

@ -49,7 +49,17 @@ class TestAsset(unittest.TestCase):
self.assertFalse(frappe.db.get_value("GL Entry",
{"voucher_type": "Purchase Invoice", "voucher_no": pi.name}))
def test_is_fixed_asset_set(self):
doc = frappe.new_doc('Purchase Invoice')
doc.supplier = '_Test Supplier'
doc.append('items', {
'item_code': 'Macbook Pro',
'qty': 1
})
doc.set_missing_values()
self.assertEquals(doc.items[0].is_fixed_asset, 1)
def test_schedule_for_straight_line_method(self):
asset = frappe.get_doc("Asset", "Macbook Pro 1")

View File

@ -218,6 +218,9 @@ class AccountsController(TransactionBase):
if stock_qty != len(get_serial_nos(item.get('serial_no'))):
item.set(fieldname, value)
if self.doctype in ["Purchase Invoice", "Sales Invoice"] and item.meta.get_field('is_fixed_asset'):
item.set('is_fixed_asset', ret.get('is_fixed_asset', 0))
if ret.get("pricing_rule"):
# if user changed the discount percentage then set user's discount percentage ?
item.set("discount_percentage", ret.get("discount_percentage"))