Raises excption if the given doc(dt, dn) is linked in another record.
Deletes a doc(dt, dn) and validates if it is not submitted and not linked in a live record
This is where all the plug-in code is executed. The standard method for DocTypes is declaration of a standardized DocType class that has the methods of any DocType. When an object is instantiated using the get_obj method, it creates an instance of the DocType class of that particular DocType and sets the doc and doclist attributes that represent the fields (properties) of that record.
methods in following modules are imported for backward compatibility
- webnotes.*
- webnotes.utils.*
- webnotes.model.doc.*
- webnotes.model.doclist.*
Execute the code, if doc is given, then return the instance of the DocType class created
Returns custom script if set in doctype Custom Script
Returns the instantiated DocType object. Here you can pass the DocType and name (ID) to get the object. If with_children is true, then all child records will be laoded and added in the doclist.
Returns the instantiated DocType object. Will also manage caching & compiling
Syncs a database table to the DocType (metadata)
Note
This module is only used internally
Basically, a wrapper for oft-used mysql commands. like show tables,databases, variables etc...
Contains the Document class representing an object / record
The wn(meta-data)framework equivalent of a Database Record. Stores,Retrieves,Updates the record in the corresponding table. Runs the triggers required.
The Document class represents the basic Object-Relational Mapper (ORM). The object type is defined by DocType and the object ID is represented by name:
Please note the anamoly in the Web Notes Framework that `ID` is always called as `name`
If both doctype and name are specified in the constructor, then the object is loaded from the database. If only doctype is given, then the object is not loaded If fielddata is specfied, then the object is created from the given dictionary.
Note 1:
The getter and setter of the object are overloaded to map to the fields of the object that are loaded when it is instantiated.
For example: doc.name will be the name field and doc.owner will be the owner field
Note 2 - Standard Fields:
- name: ID / primary key
- owner: creator of the record
- creation: datetime of creation
- modified: datetime of last modification
- modified_by : last updating user
- docstatus : Status 0 - Saved, 1 - Submitted, 2- Cancelled
- parent : if child (table) record, this represents the parent record
- parenttype : type of parent record (if any)
- parentfield : table fieldname of parent record (if any)
- idx : Index (sequence) of the child record
Returns a child record of the give childtype.
Clears the child records from the given doclist for a particular tablefield
Saves the current record in the database. If new = 1, creates a new instance of the record. Also clears temperory fields starting with __
Create a child record to the parent doc.
Example:
c = Document('Contact','ABC')
d = addchild(c, 'contact_updates', 'Contact Update', local = 1)
d.last_updated = 'Phone call'
d.save(1)
Returns a doclist containing the main record and all child records
Creates an autoname from the given key:
Autoname rules:
The key is separated by ‘.’
- ‘####’ represents a series. The string before this part becomes the prefix:
Example: ABC.#### creates a series ABC0001, ABC0002 etc
‘MM’ represents the current month
‘YY’ and ‘YYYY’ represent the current year
Example:
- DE/./.YY./.MM./.##### will create a series like DE/09/01/0001 where 09 is the year, 01 is the month and 0001 is the series
Compress a doclist before sending it to the client side. (Internally used by the request handler)
Save & return a copy of the given doclist Pass fields that are not to be copied in no_copy
Expand a doclist sent from the client side. (Internally used by the request handler)
Filter a list of records for a specific field from the full doclist
Example:
# find all phone call details
dl = getlist(self.doclist, 'contact_updates')
pl = []
for d in dl:
if d.type=='Phone':
pl.append(d)
Returns a list of values of a particualr fieldname from all Document object in a doclist
This module has the DocType class that represents a “DocType” as metadata. This is usually called by the form builder or report builder.
Add, manage, fire triggers (events / observers) Standard events called by the framework are “save, submit, cancel”
Add a trigger to an event on a doctype, docname. The specified method will be called. Wild card ‘*’ is allowed in doctype, docname and/or event_name
Fire all triggers on an event and passes the doc to the trigger
inserts a new trigger record