Daily updates from Odoo
Monday, December 4, 2017
2 changes · master
New functionality added to Odoo
This update adds a server-side form tool that lets Odoo tests simulate real user form behavior, including defaults, field changes, required fields, and read-only rules. Several accounting, sales, stock, manufacturing, and product margin tests were updated to use it, improving confidence that business flows work as expected.
Original PR description
Adds a Form view object intended to be used in test, which *should* (barring bugs) properly: * perform default_get and subsequent onchanges when creating a new record * properly call onchanges when…
Adds a Form view object intended to be used in test, which *should* (barring bugs) properly:
* perform default_get and subsequent onchanges when creating a new record
* properly call onchanges when altering fields
* reject changes to readonly fields
* not save unchanged & readonly fields
* require view-required fields
* correctly handle modifiers
* support o2m fields including `*_view_ref` hooks
* should correctly handle the "edition reference" (editable list v form)
M2M support limited to adding & removing (pre-existing) records, I think the developer can just use a separate Form if they want to create/edit those via specific views?
Example:
```python
# create a pseudo form in creation mode (empty recordset) using the specified view for e.g. readonly/required modifiers, valid fields, …
c = Form(self.env['account.voucher'], view='account_voucher.view_sale_receipt_form')
# basic fields are set directly
c.partner_id = partner_id
c.journal_id = sales_journal_id
# for o2m, "create" or "edit" a line and set its fields
with c.line_ids.new() as line:
line.name = "Voucher for Axelor"
line.account_id = account_receivable_id
line.price_unit = 1000.0
# the line is saved (in the parent, not the server) at the end of the context
# save() returns the record created (or edited, though it's not really
# necessary for an edition you can just reuse the original record)
account_voucher_customer = c.save()
```
TODO: nice docstring?
Unresoved questions:
* should `invisible` modifiers have an effect? Possibly a variant of readonly (can't edit but properly sent to the server)?
* should buttons be supported directly via the form view? Unclear how they'd be invoked since the button name can be e.g. an action id.
Replaces #20894Imported bank statements now take users straight to the reconciliation interface after import. This saves accounting teams time by reducing extra navigation and helps them start matching bank transactions immediately.
Original PR description
Task: https://www.odoo.com/web#id=32667&view_type=form&model=project.task&action=333&active_id=131&menu_id=4720 Pad: https://pad.odoo.com/p/r.bb8322647b4beaf3f7dc0494b4031959