Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def _message_order_formatter(subj, line, changed, old):
- """Format mail msg for update order lines log.
- @param subj: subject of the message
- @param line: order line
- @param changed: mapping of changed field values
- @param old: mapping of old field values
- """
- mess = subj + "<ul>"
- for fname, value in changed.iteritems():
- mess += """
- <li>{label}: {old_value} -> {new_value}</li>
- """.format(
- # TODO: translate label
- label=line._fields[fname].string,
- old_value=old[fname],
- new_value=value,
- )
- mess += "<ul>"
- return mess
- [...]
- fnames = (
- 'name', 'product_id',
- 'product_uom', 'product_uom_qty',
- )
- changed = {}
- current = self.order_line_id.read(
- fnames, load='_classic_write')[0]
- for fname in fnames:
- if not current[fname] == line_values[fname]:
- # build mapping of changed field
- # values are ($old, $new)
- changed[fname] = line_values[fname]
- if changed:
- self.order_line_id.write(changed)
- subj = 'Line {} updated'.format(self.order_line_id.name)
- self.order_id.message_post(
- body=_message_order_formatter(
- subj,
- self.order_line_id,
- changed,
- current
- ),
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement